terminate

Do IDisposable objects get disposed of if the program is shut down unexpectedly?

别等时光非礼了梦想. 提交于 2019-12-01 13:43:00
问题 What happens if the program exits unexpectedly (either by exception or the process is terminated)? Are there any situations like this (or otherwise) where the program will terminate, but IDisposable objects won't be properly disposed of? The reason I'm asking is because I'm writing code that will communicate with a peripheral, and I want to make sure there's no chance it will be left in a bad state. 回答1: If the cause is an exception and thrown from within a using block or a try catch finally

Spark Streaming: how not to restart receiver after receiver's failure

强颜欢笑 提交于 2019-12-01 13:21:29
问题 We are using a custom spark receiver that reads streamed data from a provided http link. If the provided http link is incorrect, the receiver fails. The problem is that spark will continuously restart the receiver, and the application will never terminate. The question is how to tell Spark to terminate the application if the receiver fails. This is an extract of our custom receiver: def onStart() { // Start the thread that receives data over a connection new Thread("Receiver") { override def

sh screen - Wait for screen to terminate

本秂侑毒 提交于 2019-12-01 05:04:22
问题 I'm writing on a little script that does send a command to a running screen session. This command stops the screen but not instantly. I need to wait for it to finish in order to continue with the rest of the script. This is how I stop the screen: screen -S $SCREEN_NAME -p 0 -X stuff "`printf "stop\r"`" How could I do this? 回答1: I found an solution: You just simply check if the screen is still running and wait ( sleep ) for one second. Like this: while screen -list | grep -q $SCREEN_NAME do

Flash Builder 4.5 debugger terminates | Safari

和自甴很熟 提交于 2019-11-30 19:01:44
So it seems all the major browser vendors are sandboxing the flash plugin, and terminating it after a certain amount of inactivity. This is problematic for developers who connect the Flash Builder Debugger to the browser. If you stand on a breakpoint for more than 45 seconds, it terminates your session. I've found a config param to change on firefox that disabled this functionality, but i havent found a similar command for Safari/ Webkit / Chrome. http://kb2.adobe.com/cps/899/cpsid_89943.html "To prevent Firefox from terminating plug-ins that it considers unresponsive, set dom.ipc.plugins

Difference between os.execl() and os.execv() in python

点点圈 提交于 2019-11-30 16:43:30
Is there a difference between os.execl() and os.execv() in python? I was using os.execl(python, python, *sys.argv) to restart my script (from here ). But it seems to start from where the previous script left. I want the script to start from the beginning when it restarts. Will this os.execv(__file__,sys.argv) do the job? command and idea from here. I couldn't find difference between them from the python help/documentation. Is there a way do clean restart? For a little more background on what I am trying to do please see my other question At the low level they do the same thing: they replace

PHP - exit or return which is better?

旧城冷巷雨未停 提交于 2019-11-30 10:44:22
问题 I would like to know in the following case which is a better option: In the PHP script, if the $fileSize variable is larger than 100, I stop the script; Case I: <?php if ( $fileSize > 100 ) { $results['msg'] = 'fileSize is too big!'; echo json_encode( $results ); exit(); } Case II: <?php if ( $fileSize > 100 ) { $results['msg'] = 'fileSize is too big!'; exit( json_encode( $results ) ); } Case III: <?php if ( $fileSize > 100 ) { $results['msg'] = 'fileSize is too big!'; return( json_encode(

How can I end a Lua thread cleanly?

给你一囗甜甜゛ 提交于 2019-11-30 07:16:35
问题 My situation is that I'm using the Lua (C) API to execute a script held in a string. I would like the user to be able to terminate the execution of the script (this is essential if the script contains an infinite loop), how can I do this? lua_State *Lua = lua_open(); char * code; // Initialisation code luaL_dostring(L, code); 回答1: You can use a hook to callback to C every time lua executes a line of the script. In this hook function you can check if the user wanted to quit, and call lua_error

delphi - terminate all the threads (TThread) on closing application

走远了吗. 提交于 2019-11-30 05:28:34
My application is a tcp/ip server, with main thread created only once & listening all the time. When new client connects, the main thread creates the new thread of TClientThread type. There is however no list of running Client threads, as that would make my app a bit complicated... is there any way to execute "terminate" method on all the threads, even if the thread is busy (in my case "busy" means it's waiting for the data, where the timeout set is about 30 sec ... so I have to kill it anyway, without waiting.)? The simple closing application seems not to run "terminate" method on the threads

Flash Builder 4.5 debugger terminates | Safari

别来无恙 提交于 2019-11-30 02:58:22
问题 So it seems all the major browser vendors are sandboxing the flash plugin, and terminating it after a certain amount of inactivity. This is problematic for developers who connect the Flash Builder Debugger to the browser. If you stand on a breakpoint for more than 45 seconds, it terminates your session. I've found a config param to change on firefox that disabled this functionality, but i havent found a similar command for Safari/ Webkit / Chrome. http://kb2.adobe.com/cps/899/cpsid_89943.html

Difference between os.execl() and os.execv() in python

送分小仙女□ 提交于 2019-11-29 23:40:36
问题 Is there a difference between os.execl() and os.execv() in python? I was using os.execl(python, python, *sys.argv) to restart my script (from here). But it seems to start from where the previous script left. I want the script to start from the beginning when it restarts. Will this os.execv(__file__,sys.argv) do the job? command and idea from here. I couldn't find difference between them from the python help/documentation. Is there a way do clean restart? For a little more background on what I