Skip to main content

Helper library for interacting with flexes

Project description

flexes-lib

Build Status codecov

Client library for flexes

Dependencies

For asynchronous task execution Python >= 3.5 is required.

Usage at a glance

To run a task through the API synchronously

from flexes_lib.job import run_task

message = {'service': 'echo-test', 'test': True}
result = run_task(message)
print(result['status'])
# active

Asynchronous tasks are also supported

from asyncio import get_event_loop
from flexes_lib.async_job import run_task

message = {'service': 'echo-test', 'test': True}
result = loop.run_until_complete(run_task(message))
print(result['status'])
# active

The nice thing about asynchronous tasks is that you can run them in parallel. This example submits three jobs in parallel and then waits for all three to complete before returning the results.

from asyncio import gather, get_event_loop
from flexes_lib.async_job import run_task

m1 = {'service': 'echo-test', 'test': True}
m2 = {'service': 'echo-test', 'test': True}
m3 = {'service': 'echo-test', 'test': True}
results = loop.run_until_complete(
    gather(
        run_task(m1),
        run_task(m2),
        run_task(m3)
    )
)
print([result['status'] for result in results])
# ['active', 'active', 'active']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flexes_lib-0.1.1.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file flexes_lib-0.1.1.tar.gz.

File metadata

  • Download URL: flexes_lib-0.1.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for flexes_lib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b82141073de506701fd1805a93414c951d8f6a0a558967c67c889a48a14ec151
MD5 ca56e6333a7c9c3b56ff7c38ab962453
BLAKE2b-256 ebaafaa822430649166d2a6c69a555ef4a94af35f40b3a5f584bad90a5ad8b1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page