pykka
pykka copied to clipboard
Akka-style message Scheduler
First of all, thanks for Pykka, it's really nice! There is this issue about auto-scheduling: https://github.com/jodal/pykka/issues/53
I needed this functionality for my project as well, because I believe, that an ability to use schedulers to retransmit messages, schedule job executions and so on, is quite a bit part of Akka, so I created it for myself and I hope, it could be useful for Pykka community as well.
Basically, I implemented the simplest versions of Cancellable
, Scheduler.scheduleOnce
, Scheduler.scheduleWithFixedDelay
and Scheduler.scheduleAtFixedRate
from Akka.
There are 3 schedulers for 3 different kinds of Actors:
ThreadingScheduler
- based on threading.Timer
.
EventletScheduler
- based on eventlet.spawn_after
.
GeventScheduler
- based on gevent.spawn_later
.
I believe, that's possibly a typo:
https://github.com/jodal/pykka/blob/4c4c9a7fb67464576eb558b8a7e72e3b26cfe285/pykka/eventlet.py#L43
Neither of EventletEvent
and eventlet.event.Eventlet
has event
attribute. So, probably, it should be self.wait()
or super().wait()
.
Didn't try to "fix" it, because I'm not sure what exactly it should be.
Meanwhile flake8
is angry about _future.pyi
that I didn't touch. Other checks pass.
Codecov Report
Merging #95 into develop will increase coverage by
0.51%
. The diff coverage is99.00%
.
@@ Coverage Diff @@
## develop #95 +/- ##
===========================================
+ Coverage 95.37% 95.88% +0.51%
===========================================
Files 13 14 +1
Lines 562 656 +94
===========================================
+ Hits 536 629 +93
- Misses 26 27 +1
Impacted Files | Coverage Δ | |
---|---|---|
pykka/_scheduler.py | 98.68% <98.68%> (ø) |
|
pykka/_threading.py | 96.61% <100.00%> (+0.38%) |
:arrow_up: |
pykka/eventlet.py | 91.17% <100.00%> (+0.85%) |
:arrow_up: |
pykka/gevent.py | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 4c4c9a7...4863fc3. Read the comment docs.
The code in this PR that calls time.time()
really should be updated to use a monotonic timer.
@jodal any plan on having this merged at some point? This is also a much needed feature. There are workarounds but would be nice to have something in Pykka directly.
Still, it would be nice to have it playing nicely with proxies also.
@lostcontrol I believe, this PR is extremely outdated, Pykka 3 is pretty different to the version that I had, when I was working this PR. It would need heavy refactoring. And there is a number of possible improvements, like the one, that @djmattyg007 mentioned. I'd be happy to refactor it, improve it and resolve all the conflicts, but I am not sure whether it makes any sense since there is no reaction from @jodal on any of opened PRs.