Skip to content

Commit

Permalink
aio-libs#506 anyio integration - initial
Browse files Browse the repository at this point in the history
  • Loading branch information
madkote committed Feb 21, 2023
1 parent 2218a18 commit af937a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions janus/__init__.py
@@ -1,3 +1,4 @@
import anyio
import asyncio
import sys
import threading
Expand All @@ -7,7 +8,7 @@
from heapq import heappop, heappush
from queue import Empty as SyncQueueEmpty
from queue import Full as SyncQueueFull
from typing import Any, Callable, Deque, Generic, List, Optional, Set, TypeVar
from typing import Any, Callable, Deque, Generic, List, Optional, Set, TypeVar # noqa F401

from typing_extensions import Protocol

Expand Down Expand Up @@ -223,14 +224,16 @@ def f() -> None:
with self._sync_mutex:
self._sync_not_empty.notify()

self._loop.run_in_executor(None, f)
asyncio.ensure_future(anyio.to_thread.run_sync(f, *[]))
# self._loop.run_in_executor(None, f)

def _notify_sync_not_full(self) -> None:
def f() -> None:
with self._sync_mutex:
self._sync_not_full.notify()

fut = asyncio.ensure_future(self._loop.run_in_executor(None, f))
fut = asyncio.ensure_future(anyio.to_thread.run_sync(f, *[]))
# fut = asyncio.ensure_future(self._loop.run_in_executor(None, f))
fut.add_done_callback(self._pending.discard)
self._pending.add(fut)

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -48,6 +48,7 @@ include_package_data = True

install_requires =
typing-extensions>=3.7.4.3
anyio>=3.6.2

[flake8]
exclude = .git,.env,__pycache__,.eggs
Expand Down

0 comments on commit af937a3

Please sign in to comment.