kick1911 / workforce Goto Github PK
View Code? Open in Web Editor NEWAsyncio Wrapper
License: BSD 3-Clause "New" or "Revised" License
Asyncio Wrapper
License: BSD 3-Clause "New" or "Revised" License
Prepare for an initial release.
Add more tests for:
Do we need the ability to retry tasks? or should the dev handle retires themselves since some libraries have that builtin like requests
.
What must we do if someone does this?
@workforce.task(callback=callback)
async def add(a, b):
return a + b
task = add.s(4, 5)(callback=foo)
WorkForce/workforce_async/models.py
Line 165 in a2ea955
Make interface more seemless by using iscoroutinefunction()
Introduce the manager concept.
Example:
A manager that can increase/decrease the number of workspaces based on load.
platform linux -- Python 3.6.12[pypy-7.3.3-final], pytest-5.4.3, py-1.10.0, pluggy-0.13.1
task = add.s(4, 5)
time.sleep(0.5)
assert task.done()
> assert task.result() == 9
E assert None == 9
E + where None = <bound method Future.result of <Task finished coro=<wait_for() done, defined at /home/kick/.pyenv/versions/pypy3.6-7.3.3/lib-python/3/asyncio/tasks.py:321> result=Non
e>>()
E + where <bound method Future.result of <Task finished coro=<wait_for() done, defined at /home/kick/.pyenv/versions/pypy3.6-7.3.3/lib-python/3/asyncio/tasks.py:321> result=None>> =
<Task finished coro=<wait_for() done, defined at /home/kick/.pyenv/versions/pypy3.6-7.3.3/lib-python/3/asyncio/tasks.py:321> result=None>.result
tests/test_workforce.py:151: AssertionError
f = workforce.schedule_async(foo)
time.sleep(0.5)
assert f.done()
> assert f.exception() == ex
E AssertionError: assert None == Exception('Error occured',)
E + where None = <bound method Future.exception of <Task finished coro=<wait_for() done, defined at /home/kick/.pyenv/versions/pypy3.6-7.3.3/lib-python/3/asyncio/tasks.py:321> result=None>>()
E + where <bound method Future.exception of <Task finished coro=<wait_for() done, defined at /home/kick/.pyenv/versions/pypy3.6-7.3.3/lib-python/3/asyncio/tasks.py:321> result=None>> = <Task finished coro=<wait_for() done, defined at /home/kick/.pyenv/versions/pypy3.6-7.3.3/lib-python/3/asyncio/tasks.py:321> result=None>.exception
tests/test_workforce.py:180: AssertionError
I think time.sleep
works weirdly or some async stuff work weirdly
Ability to register a queue with a unique id and add tasks to that queue to be completed incrementally.
Edited:
Probably use below to on a Manager to store state. (This implies new instance of Manager per workflow)
https://docs.python.org/3/library/asyncio-queue.html#queue
Assume Callable item is put into the queue.
WorkForce/workforce_async/models.py
Lines 51 to 52 in a2ea955
Create a workspace Manager to allow custom workspace interface.
WorkForce/workforce_async/models.py
Line 274 in a2ea955
Also, add a toolbox to the Workspace that will be passed to tasks as context.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.