Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python async libraries run many I/O-bound tasks concurrently in one thread by switching between them while each waits on the network or disk. An event loop schedules each coroutine or green thread and resumes it when its I/O completes. These libraries let web servers, crawlers, and AI agents handle thousands of open connections at once.
Popularity
AnyIO has the most monthly downloads among the registry packages in this comparison, at 1.0B.
def _run_server_loop(main: Coroutine[Any, Any, None]) -> None:
"""Run ``main`` on a new event loop, using uvloop when available.
- uvloop provides ``new_event_loop``: run on ``asyncio.Runner`` so we
avoid the deprecated event-loop policy APIs.
- uvloop is missing or too old: call ``uvloop.install()`` when it exists,
then ``asyncio.run()``.
- Creating the uvloop loop fails: skip ``install()`` and use the stdlib
loop.
"""
loop_factory = _get_uvloop_loop_factory()
if loop_factory is None:
_try_install_uvloop()
else:
try:
# Create the loop before Runner.run so a factory failure can # fall back without wrapping the server coroutine itself. loop = loop_factory()
except Exception:
# Don't call install() here: that would retry the same uvloop # implementation that just failed to create a loop. _LOGGER.warning(
"Failed to create uvloop event loop. Falling back to default loop.",
exc_info=True,
)
else:
_LOGGER.debug("Starting new uvloop event loop for server")
with asyncio.Runner(loop_factory=lambda: loop) as runner:
runner.run(main)
return
_LOGGER.debug("Starting new event loop for server")
asyncio.run(main)
Tornado
Provides a web framework and asynchronous networking library.
def send_ping(self):
"""send a ping to keep the websocket alive"""
if self.ws_connection is None and self.ping_callback is not None:
self.ping_callback.stop()
return
if self.ws_connection.client_terminated:
self.close()
return
# check for timeout on pong. Make sure that we really have sent a recent ping in # case the machine with both server and client has been suspended since the last ping. now = ioloop.IOLoop.current().time()
since_last_pong = 1e3 * (now - self.last_pong)
since_last_ping = 1e3 * (now - self.last_ping)
if since_last_ping < 2 * self.ping_interval and since_last_pong > self.ping_timeout:
self.log.warning("WebSocket ping timeout after %i ms.", since_last_pong)
self.close()
return
self.ping(b"")
self.last_ping = now
Trio
Provides native async/await I/O with nurseries and cancellation scopes.
Downloads / mo
42.5M
Stars
7.4K
Last release
0.35.0
License
MIT OR Apache-2.0
Strengths
Nurseries contain child-task lifetimes.Nursery exit waits for every child task to finish.
Groups deadlines and cancellation.Use cancel scopes to apply deadlines or cancellation to enclosed operations.
Limitations
Cancellation waits for checkpoints.Add checkpoints to CPU-bound loops that must respond to cancellation.
def map(requests, stream=False, size=None, exception_handler=None, gtimeout=None):
"""Concurrently converts a list of Requests to Responses.
:param requests: a collection of Request objects.
:param stream: If True, the content will not be downloaded immediately.
:param size: Specifies the number of requests to make at a time. If None, no throttling occurs.
:param exception_handler: Callback function, called when exception occured. Params: Request, Exception
:param gtimeout: Gevent joinall timeout in seconds. (Note: unrelated to requests timeout)
"""
requests = list(requests)
pool = Pool(size) if size else None
jobs = [send(r, pool, stream=stream) for r in requests]
gevent.joinall(jobs, timeout=gtimeout)
ret = []
for request in requests:
if request.response is not None:
ret.append(request.response)
elif exception_handler and hasattr(request, 'exception'):
ret.append(exception_handler(request, request.exception))
elif exception_handler and not hasattr(request, 'exception'):
ret.append(exception_handler(request, None))
else:
ret.append(None)
return ret
async def _report_results_to_bridgecrew_async(
scan_results: Iterable[dict[str, Any]],
bc_integration: BcPlatformIntegration,
bc_api_key: str,
) -> Sequence[int]:
package_scanning_int = PackageScanningIntegration()
args = [(result, bc_integration, bc_api_key, Path(result["repository"])) for result in scan_results]
if os.getenv("PYCHARM_HOSTED") == "1":
# PYCHARM_HOSTED env variable equals 1 when running via Pycharm. # it avoids us from crashing, which happens when using multiprocessing via Pycharm's debug-mode logging.warning("reporting the results in sequence for avoiding crashing when running via Pycharm")
exit_codes = []
for curr_arg in args:
exit_codes.append(await package_scanning_int.report_results_async(*curr_arg))
else:
async with Pool() as pool:
exit_codes = await pool.starmap(package_scanning_int.report_results_async, args)
return exit_codes
def spawn_n(self, *args, **kwargs):
super(RestrictedGreenPool, self).spawn_n(*args, **kwargs)
if self._rgp_do_wait:
self.waitall()
FAQ
AnyIO suits libraries that must run on both asyncio and Trio. uvloop suits asyncio servers that want a faster event loop. gevent suits older synchronous code that needs concurrency without async syntax.
asyncio is the standard library framework for async and await code in Python. It provides the event loop, tasks, and streams that AnyIO and uvloop build on.
AnyIO provides structured concurrency and async I/O APIs that run on top of asyncio or Trio. Its task groups cancel sibling tasks together when one task fails.
uvloop replaces the default asyncio event loop with one built on libuv. Servers install it with a single call at startup.
gevent runs cooperative networking on greenlets behind a synchronous-style API. Monkey-patching makes standard library sockets yield to other greenlets.
asyncio runs coroutines on one thread and switches tasks only at each await. Threading runs functions on operating system threads that the scheduler can switch at any point.
For coding agents
Found your async library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.