Commit 2820dc1c authored by Leo Pound Singer's avatar Leo Pound Singer

Add thread safety example

parent a6564a97
Pipeline #110228 passed with stages
in 1 minute and 37 seconds
......@@ -217,6 +217,26 @@ class LVAlertClient(slixmpp.ClientXMPP):
If the client has been started by calling :meth:`start`, then
:meth:`start` will return and the connection will be closed.
Notes
-----
This method is thread safe, so you can use it to stop the client from
another thread. For example:
.. code-block:: python
from threading import Thread
from time import sleep
client = LVAlertClient()
def wait_then_stop():
sleep(5)
client.stop()
Thread(target=wait_then_stop).start()
client.start()
"""
self.loop.call_soon_threadsafe(self._stop)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment