Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8963785
)
python: Improved current-watcher implementation.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 22 Jun 2016 02:30:06 +0000
(
04:30
+0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 22 Jun 2016 02:30:06 +0000
(
04:30
+0200)
python3/ashd/async.py
patch
|
blob
|
blame
|
history
diff --git
a/python3/ashd/async.py
b/python3/ashd/async.py
index
e30f858
..
99da89a
100644
(file)
--- a/
python3/ashd/async.py
+++ b/
python3/ashd/async.py
@@
-3,12
+3,15
@@
import sys, os, errno, threading, select, traceback
class epoller(object):
exc_handler = None
class epoller(object):
exc_handler = None
- def __init__(self):
+ def __init__(self
, check=None
):
self.registered = {}
self.lock = threading.RLock()
self.ep = None
self.th = None
self.stopped = False
self.registered = {}
self.lock = threading.RLock()
self.ep = None
self.th = None
self.stopped = False
+ self.loopcheck = set()
+ if check is not None:
+ self.loopcheck.add(check)
self._daemon = True
@staticmethod
self._daemon = True
@staticmethod
@@
-56,6
+59,8
@@
class epoller(object):
self.ep = ep
while self.registered:
self.ep = ep
while self.registered:
+ for ck in self.loopcheck:
+ ck(self)
if self.stopped:
self._closeall()
break
if self.stopped:
self._closeall()
break
@@
-278,8
+283,7
@@
class callbuffer(channel):
self.wp = -1
def currentwatcher(io, current):
self.wp = -1
def currentwatcher(io, current):
- def run():
- while current:
- current.wait()
- io.stop()
- threading.Thread(target=run, name="Current watcher").start()
+ def check(io):
+ if not current:
+ io.stop()
+ io.loopcheck.add(check)