{"id":24793,"library":"unsync","title":"unsync","description":"unsync is a decorator-based library that bridges synchronous and asynchronous Python code. It allows you to call async functions from sync code and vice versa without manually managing event loops. Current version is 1.4.0. Release cadence is low; last release was in 2020.","status":"active","version":"1.4.0","language":"python","source_language":"en","source_url":"https://github.com/alex-sherman/unsync","tags":["async","synchronous","decorator","asyncio","bridge"],"install":[{"cmd":"pip install unsync","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"Importing the module directly without the decorator name will not give you the decorator function.","wrong":"import unsync","symbol":"unsync","correct":"from unsync import unsync"},{"note":"Exception raised for unsupported operations.","symbol":"UnsupportedError","correct":"from unsync import UnsupportedError"}],"quickstart":{"code":"from unsync import unsync\nimport asyncio\n\n@unsync\nasync def async_function():\n    await asyncio.sleep(0.1)\n    return \"Hello from async\"\n\nresult = async_function()\nprint(result)","lang":"python","description":"Decorate an async function with @unsync to call it from synchronous code; the decorated function returns a concurrent.futures.Future or similar object."},"warnings":[{"fix":"Use await directly when already in an async function instead of @unsync.","message":"Using @unsync in an async context (e.g., inside another async function) may cause unexpected behavior; prefer direct await.","severity":"gotcha","affected_versions":"all"},{"fix":"Call .result() on the returned object to get the value (e.g., async_function().result()).","message":"The unsync decorator returns a future-like object, not the immediate result; you must call .result() or iterate accordingly.","severity":"gotcha","affected_versions":"all"},{"fix":"Use asyncio.run() for top-level async calls instead of relying on unsync's loop management.","message":"Global event loops can cause issues if multiple event loops are created, especially in test suites.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure there is a running event loop, or use asyncio.run() or unsync's own setup if in a synchronous context.","cause":"Calling an unsync-decorated function from a context where no event loop is running.","error":"RuntimeError: There is no current event loop in thread 'MainThread'."},{"fix":"Use 'from unsync import unsync' to import the decorator.","cause":"Importing unsync with 'import unsync' instead of 'from unsync import unsync'.","error":"AttributeError: module 'unsync' has no attribute 'unsync'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}