mirror of
https://github.com/powerline/powerline.git
synced 2025-07-29 16:55:07 +02:00
pyuv: make stopping the loop thread-safe
This commit is contained in:
parent
f34ab66ea2
commit
36737867b1
@ -34,14 +34,18 @@ class UvThread(Thread):
|
|||||||
|
|
||||||
def __init__(self, loop):
|
def __init__(self, loop):
|
||||||
self.uv_loop = loop
|
self.uv_loop = loop
|
||||||
|
self.async_handle = pyuv.Async(loop, self._async_cb)
|
||||||
super(UvThread, self).__init__()
|
super(UvThread, self).__init__()
|
||||||
|
|
||||||
|
def _async_cb(self, handle):
|
||||||
|
self.uv_loop.stop()
|
||||||
|
self.async_handle.close()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
self.uv_loop.run()
|
||||||
self.uv_loop.run()
|
|
||||||
|
|
||||||
def join(self):
|
def join(self):
|
||||||
self.uv_loop.stop()
|
self.async_handle.send()
|
||||||
return super(UvThread, self).join()
|
return super(UvThread, self).join()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user