Sidnicious/runloop.py — pull request #1 by maintainer (2014-11-27 05:23:43+00:00)
Title: Fix runloop stop method.

Problem: if runloop queue is empty stop() method can't stop loop

Before fix:

Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type help, copyright, credits or license for more information.
>>> from runloop import RunLoop
>>> from threading import Timer
>>> rl = RunLoop()
>>> Timer(5, rl.stop).start()
>>> rl.run()

# run loop will not stop after 5 seconds

After fix:

Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type help, copyright, credits or license for more information.
>>> from runloop import RunLoop
>>> from threading import Timer
>>> rl = RunLoop()
>>> Timer(5, rl.stop).start()
>>> rl.run()
>>>
# run loop stopped after waiting 5 seconds