Skip to main content

aioify (maintenance mode)

Authors of aioify and module-wrapper decided to discontinue support of these libraries since the idea: "let's convert sync libraries to async ones" works only for some cases. Existing releases of libraries won't be removed, but don't expect any changes since today. Feel free to fork these libraries, however, we don't recommend using the automatic sync-to-async library conversion approach, as unreliable. Instead, it's better to run synchronous functions asynchronously using https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor or https://anyio.readthedocs.io/en/stable/api.html#running-code-in-worker-threads.

Old documentation

Make every function async and await-able.

Usage

pip install aioify

For example, make os, shutil and user defined function await-able.

#!/usr/bin/env python
###########
# Warning #
###########
# This code should be executed only on POSIX OS with at least 1 GiB free space in /tmp/ directory and RAM!

from aioify import aioify
import os
import shutil


def generate_big_file(filename, file_size):
    with open(file=filename, mode='wb') as f:
        f.write(os.urandom(file_size))


aiogenerate_big_file = aioify(obj=generate_big_file)
aios = aioify(obj=os, name='aios')
aioshutil = aioify(obj=shutil, name='aishutil')


async def main():
    dir_path = '/tmp/big-files/'
    await aios.makedirs(name=dir_path, exist_ok=True)
    filename = os.path.join(dir_path, 'original')
    copy_filename = os.path.join(dir_path, 'copy')
    file_size = 1024 * 1024 * 1024
    await aiogenerate_big_file(filename=filename, file_size=file_size)
    await aioshutil.copy(src=filename, dst=copy_filename)
    await aioshutil.rmtree(path=dir_path)


if __name__ == '__main__':
    import asyncio as aio
    loop = aio.get_event_loop()
    loop.run_until_complete(main())

Metadata

Release files for aioify 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aioify 0.4.1
File Size Uploaded
aioify-0.4.1.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aioify 0.4.1
File Interpreter ABI Platform
aioify-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / aioify-0.4.1.tar.gz

Download URL aioify-0.4.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
433b869662108649f8c263694c12cb93bc80d2d9ba715f17b0f03017aa56c721
BLAKE2b-256 checksum
How to use checksums
d57d406950e7ad66518372baa1e44921791266f700ab9cea88e76917488c6ceb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.13 Linux/5.16.15-1-default

Release files / aioify-0.4.1-py3-none-any.whl

Download URL aioify-0.4.1-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd862a4a936608336d36e81aeca6219414cef1a7a383831c6d8863102ff3b323
BLAKE2b-256 checksum
How to use checksums
bb4a6daf82516a579ba9be029469acfb46e567a743a30218118383f90194d281
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.13 Linux/5.16.15-1-default

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.0

1 release file

0.1.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page