projects
/
saartuer.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1b72ccf
)
thread instead of multiprocessing for fire_and_forget
author
Constantin Berhard
<constantin@exxxtremesys.lu>
Wed, 9 Oct 2013 19:03:29 +0000
(21:03 +0200)
committer
Constantin Berhard
<constantin@exxxtremesys.lu>
Wed, 9 Oct 2013 19:03:29 +0000
(21:03 +0200)
libtuer.py
patch
|
blob
|
history
diff --git
a/libtuer.py
b/libtuer.py
index e31ce2728497f1c2dab8bfadad7d3b7a153ec41c..5b1221c173865efab6efa3ce1f55b32af891f2c8 100644
(file)
--- a/
libtuer.py
+++ b/
libtuer.py
@@
-1,4
+1,4
@@
-import logging, logging.handlers, os, time, queue, threading, subprocess
, multiprocessing
+import logging, logging.handlers, os, time, queue, threading, subprocess
# logging function
class Logger:
# logging function
class Logger:
@@
-31,13
+31,13
@@
logger = Logger()
# run a command asynchronously and log the return value if not 0
# prefix must be a string identifying the code position where the call came from
def fire_and_forget (cmd, log, prefix):
# run a command asynchronously and log the return value if not 0
# prefix must be a string identifying the code position where the call came from
def fire_and_forget (cmd, log, prefix):
- def _fire_and_forget (
cmd, log, prefix
):
+ def _fire_and_forget ():
with open("/dev/null", "w") as fnull:
retcode = subprocess.call(cmd, stdout=fnull, stderr=fnull)
if retcode is not 0:
log("%sReturn code %d at command: %s" % (prefix,retcode,str(cmd)))
with open("/dev/null", "w") as fnull:
retcode = subprocess.call(cmd, stdout=fnull, stderr=fnull)
if retcode is not 0:
log("%sReturn code %d at command: %s" % (prefix,retcode,str(cmd)))
-
p = multiprocessing.Process(target=_fire_and_forget, args=(cmd,log,prefix)
)
-
p
.start()
+
t = threading.Thread(target=_fire_and_forget
)
+
t
.start()
# Threaded callback class
class ThreadFunction():
# Threaded callback class
class ThreadFunction():