Skip to content

Instantly share code, notes, and snippets.

View johanste's full-sized avatar

Johan Stenberg (MSFT) johanste

  • Microsoft Corporation
  • Redmond, WA
View GitHub Profile
@johanste
johanste / wrap_async_in_sync.py
Created February 25, 2019 16:54
Wrapping async in sync
import asyncio
import threading
class Client:
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.loop.call_soon_threadsafe(self.loop.stop)
@johanste
johanste / pipeline.py
Created January 17, 2019 18:52
Example semi-strongly typed pipeline
from sys import Type
from typing import List
class Policy:
...
class RetryPolicy(Policy):
def __init__(self, max_retries=4, timeout=None):