Commit Graph

18 Commits

Author SHA1 Message Date
Kevin O'Connor 1af4a4ae9f reactor: Record time of recent gc collection sweeps
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-17 02:06:20 -04:00
Kevin O'Connor cb0a8f2ed9 reactor: Add support for explicit Python garbage collection
Add support for performing Python gc work only from the main reactor
thread and only when it appears the main thread is idle.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-16 23:53:45 -04:00
Kevin O'Connor 7d83aed410 reactor: Terminate any greenlets on finalize() call
Make sure to terminate any greenlets that are in a pause() state.
This is necessary to ensure the reactor can be deallocated.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-16 23:53:45 -04:00
Kevin O'Connor 760a0f8df5 reactor: Add explicit finalize() method to clean up reactor state
The existence of a __del__() method prevents deallocation on python2
if there are circular references.  Replace the __del__() method with a
new finalize() call and arrange for it to be called when the main
reactor is released.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-16 23:53:45 -04:00
Kevin O'Connor 4905667ee2 reactor: Use "import Queue as queue" for improved Python3 compatibility
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-06-15 17:15:53 -04:00
Kevin O'Connor e3a5e2d271 reactor: Support multiple waiting timers on a single completion
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-02-19 10:49:56 -05:00
Kevin O'Connor 233da97b19 reactor: Add support for "completions"
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-10 10:43:20 -04:00
Kevin O'Connor 077c6f7e5e reactor: Fix some corner cases with self._next_timer handling
Make sure to update self._next_timer on greenlet start/stop.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-19 21:12:34 -04:00
Kevin O'Connor afc10400e3 reactor: Be explicit on which handlers are timer_handler vs file_handler
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-09 18:44:44 -04:00
Kevin O'Connor 0546c18d27 reactor: Add support for mutexes
Add a mutex object that implements simple queing mutual exclusion for
greenlets.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-09 12:55:56 -04:00
Janar Sööt 265769787f reactor: support for delayed callbacks
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
2019-01-07 21:38:36 -05:00
Kevin O'Connor 4061026c25 reactor: Add ability to register callbacks
Add the ability to register callbacks - both asynchronous (ie, from
another thread) and synchronous.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-30 14:13:47 -04:00
Kevin O'Connor 1592395036 reactor: Fix bug causing end() to not always work
Only set the self._process flag in run() not _dispatch_loop().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-13 13:20:13 -04:00
Kevin O'Connor 565861f680 reactor: Support pause() command even when the reactor is not running
If the reactor isn't running then implement pause using the system
sleep command.  This simplifies the users of pause().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-01 12:26:24 -04:00
Kevin O'Connor 20d0936fa2 reactor: Use the system monotonic clock instead of the normal system clock
The normal system clock can have sudden jumps if the system clock is
changed.  Use the system monotonic clock to avoid these sudden changes
in time.

It appears the Raspbian OS (which is used by OctoPi) is setup to
update the system clock upon network connectivity.  This could cause
sudden system clock changes which could lead to Klippy processing
errors.  Using the monotonic clock eliminates these issues.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-02-06 13:31:34 -05:00
Kevin O'Connor 46b6b4037d reactor: Reload eventtime if a greenlet is reactivated
Fix a bug causing timers to be delayed when pause() is called from a
fd event.  The eventtime needs to be reloaded when an old greenlet is
reactivated.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-01-10 11:19:39 -05:00
Kevin O'Connor bafe796eeb reactor: Add support for greenlets
Add support for greenlets - a mechanism for tasks that can pause while
still allowing regular reactor events to occur.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-29 21:54:45 -05:00
Kevin O'Connor f582a36e4d Initial commit of source code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-05-25 11:37:40 -04:00