Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTP webserver interface #6

Merged
merged 16 commits into from
Nov 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Run first extraction before starting webserver
It leaves less time for client to hit 503 error on startup, but more importantly, it deals with race condition in startup sequence: if extractor_task gets interrupted after webserver startup was initiated but before make_server() returned, then potoken_server.stop() becomes a no-op, leaving background task with webserver to run indefinitely.
15532th authored and unixfox committed Nov 17, 2024
commit 3b3a5c4b41a60d7c028d5314dbf5aaebc19253f3
2 changes: 1 addition & 1 deletion potoken_generator/main.py
Original file line number Diff line number Diff line change
@@ -30,8 +30,8 @@ def print_token_and_exit(token_info: Optional[TokenInfo]):
async def run(loop: asyncio.AbstractEventLoop, oneshot: bool,
update_interval: int, bind_address: str, port: int) -> None:
potoken_extractor = PotokenExtractor(loop, update_interval=update_interval)
token = await potoken_extractor.run_once()
if oneshot:
token = await potoken_extractor.run_once()
print_token_and_exit(token)

extractor_task = loop.create_task(potoken_extractor.run())