mirror of https://github.com/nocturn9x/giambio.git
Added some exclude paths to gitignore
This commit is contained in:
parent
e29eaf3862
commit
70646a4767
|
@ -83,6 +83,7 @@ ipython_config.py
|
|||
|
||||
# pyenv
|
||||
.python-version
|
||||
pyenv.cfg
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
|
@ -103,6 +104,8 @@ celerybeat.pid
|
|||
|
||||
# Environments
|
||||
.env
|
||||
bin
|
||||
lib
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
|
|
|
@ -63,7 +63,8 @@ class TaskManager:
|
|||
for task in self.tasks:
|
||||
try:
|
||||
await task.join()
|
||||
except BaseException as e:
|
||||
except BaseException:
|
||||
self.tasks.remove(task)
|
||||
for to_cancel in self.tasks:
|
||||
await to_cancel.cancel()
|
||||
print("oof")
|
|
@ -228,7 +228,7 @@ class AsyncScheduler:
|
|||
|
||||
def reschedule_joinee(self):
|
||||
"""
|
||||
Reschedules the joinee(s) task of the
|
||||
Reschedules the joinee(s) of the
|
||||
currently running task, if any
|
||||
"""
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
home = /usr
|
||||
implementation = CPython
|
||||
version_info = 3.7.3.final.0
|
||||
virtualenv = 20.1.0
|
||||
include-system-site-packages = false
|
||||
base-prefix = /usr
|
||||
base-exec-prefix = /usr
|
||||
base-executable = /usr/bin/python3
|
|
@ -1,25 +0,0 @@
|
|||
import giambio
|
||||
|
||||
|
||||
async def child(sleep: int, ident: int):
|
||||
start = giambio.clock() # This returns the current time from giambio's perspective
|
||||
print(f"[child {ident}] Gonna sleep for {sleep} seconds!")
|
||||
await giambio.sleep(sleep)
|
||||
end = giambio.clock() - start
|
||||
print(f"[child {ident}] I woke up! Slept for {end} seconds")
|
||||
|
||||
|
||||
async def main():
|
||||
print("[parent] Spawning children")
|
||||
task = giambio.spawn(child, 1, 1) # We spawn a child task
|
||||
task2 = giambio.spawn(child, 2, 2) # and why not? another one!
|
||||
start = giambio.clock()
|
||||
print("[parent] Children spawned, awaiting completion")
|
||||
await task.join()
|
||||
await task2.join()
|
||||
end = giambio.clock() - start
|
||||
print(f"[parent] Execution terminated in {end} seconds")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
giambio.run(main) # Start the async context
|
|
@ -17,10 +17,11 @@ async def serve(address: tuple):
|
|||
asock = giambio.wrap_socket(sock) # We make the socket an async socket
|
||||
logging.info(f"Serving asynchronously at {address[0]}:{address[1]}")
|
||||
async with giambio.create_pool() as pool:
|
||||
conn, addr = await asock.accept()
|
||||
logging.info(f"{addr[0]}:{addr[1]} connected")
|
||||
pool.spawn(handler, conn, addr)
|
||||
|
||||
while True:
|
||||
conn, addr = await asock.accept()
|
||||
logging.info(f"{addr[0]}:{addr[1]} connected")
|
||||
pool.spawn(handler, conn, addr)
|
||||
print("oof done")
|
||||
|
||||
async def handler(sock: AsyncSocket, addr: tuple):
|
||||
addr = f"{addr[0]}:{addr[1]}"
|
||||
|
|
Loading…
Reference in New Issue