Skip to content

Instantly share code, notes, and snippets.

@oakkitten
oakkitten / AsyncIterator.kt
Last active November 13, 2020 10:14
Asynchronous iterator in Kotlin
package asynciterator
import kotlinx.coroutines.*
import kotlin.coroutines.intrinsics.createCoroutineUnintercepted
import kotlin.coroutines.*
import kotlin.experimental.ExperimentalTypeInference
import kotlin.system.getTimeMillis
interface AsyncCoroutineScope<T> : CoroutineScope {
@oakkitten
oakkitten / LICENSE
Last active July 7, 2021 13:21
Attrs with star attributes
Copyright (c) 2021 oakkitten
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@oakkitten
oakkitten / test_shy.py
Created June 14, 2020 10:21
Shy trio fixtures
import pytest
import trio
from contextlib import contextmanager
from functools import wraps
from pytest_trio.plugin import TrioFixture
from inspect import isasyncgenfunction
def shy_in_presence_of(*names):
def decorator(func):
@oakkitten
oakkitten / experimental.py
Last active January 20, 2021 22:37
A bit crazy parameter passing with pytest
from plugin import parameters, arguments, Fixture
from plugin import fixture_taking_arguments as fixture
from types import SimpleNamespace
from functools import partial
from dataclasses import dataclass
import pytest
from _pytest.python import CallSpec2