Compare commits

...

2 commits

5 changed files with 50 additions and 0 deletions

View file

@ -30,6 +30,7 @@ app = [
"zope.traversing",
]
auth = ["pyjwt[crypto]", "cryptography", "requests"]
fastapi = ["fastapi[standard]"]
test = ["zope.testrunner"]
#test = ["pytest"]

1
scopes/api/__init__.py Normal file
View file

@ -0,0 +1 @@
"""package scopes.api"""

14
scopes/api/main.py Normal file
View file

@ -0,0 +1,14 @@
# package scopes.api.main
from fastapi import FastAPI
app = FastAPI()
@app.get('/')
def read_root():
return {'Hello': 'World'}
@app.get('/persons/{name}')
def read_person(name: str, q: str | None = None):
return {'name': name, 'query': q}

1
scopes/core/__init__.py Normal file
View file

@ -0,0 +1 @@
"""package scopes.core"""

33
scopes/core/actor.py Normal file
View file

@ -0,0 +1,33 @@
""" package scopes.core.actor """
import asyncio
quit = object()
async def loop(q, bhv):
while True:
msg = await q.get()
if msg == quit:
break
bhv(msg)
def create(q, bhv):
return asyncio.create_task(loop(q, bhv))
# some simple behaviors
def show(msg):
print(msg)
# main
async def main():
q = asyncio.Queue()
task = create(q, show)
await q.put("Hello World!")
await q.put(quit)
await task
def run():
asyncio.run(main())