Skip to main content

README

py_easy_async provides simple interface for threading to easy perform async actions in Python versions 3.4 and up

Example of simple async operations

import py_easy_async
import time

def print_with_sleep(word):
    time.sleep(1)
    print(word)
    return 'done'

print('first')
py_easy_async.async(lambda: print_with_sleep('second'),
                 lambda done_string: print("done callback called with string: %s" % done_string))
print('third')

The above example will print the following:

first
third
second
done callback called with string: done

Example of thread pool management

from py_easy_async import pool

def message_handler(message):
    print('got message:', message)

identifier = pool.run_thread(message_handler, name='Persistent-Thread')

for i in range(5):
    pool.message(identifier, "test message #%s" % i)

pool.stop_thread(identifier)

The above example will start thread that will wait for messages that it should process:

Persistent-Thread starting...

got message: test message #0
got message: test message #1
got message: test message #2
got message: test message #3
got message: test message #4

Persistent-Thread exiting...

License

Released under the MIT license.

Installation

pip install py_easy_async

Metadata

Release files for py_easy_async 0.1.2

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

Source distribution (sdist)

Source distribution for py_easy_async 0.1.2
File Size Uploaded
py_easy_async-0.1.2.tar.gz 2.6 kB Details

Release files / py_easy_async-0.1.2.tar.gz

Download URL py_easy_async-0.1.2.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ccee03a2720fb00547efe4c97497b4ef7ad21d44c1931aa3eee4e5721e92bff9
BLAKE2b-256 checksum
How to use checksums
04c08aa951d3bbeef2c59bd4f1ffa67844a8be71365e1508ce41cbfc4513e115
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1

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