Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

icij-worker

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icij-worker

Create asynchronous tasks from Python functions

  • 0.12.0
  • PyPI
  • Socket score

Maintainers
3

ICIJ's async worker library Test for icij-worker

Installation

With AMQP:

pip install icij-worker["amqp"]

With neo4j:

pip install icij-worker["neo4j"]

Usage

Create an async app and register tasks

Create asynchronous task tailored for long running Python functions:

Given the following pure Python function inside the app.py module:

def long_running_task(greeted: str) -> str:
    greeting = f"Hello {greeted} !"
    return greeting

decorate your function with ICIJApp class and register a new task:

from icij_worker import AsyncApp

my_app = AsyncApp(name="my_app")

@my_app.task
def long_running_task(greeted: str) -> str:
    greeting = f"Hello {greeted} !"
    return greeting

this will register the long_running_task function under the long_running_task task name.

Optionally add progress handlers for a better task monitoring:

@my_app.task
async def long_running_task(
    greeted: str,
    progress: Optional[Callable[[float], Awaitable]] = None
) -> str:
    if progress is not None:
        await progress(0.0)
    greeting = f"Hello {greeted} !"
    if progress is not None:
        await progress(100.0)
    return greeting

Launch a async worker pool

Start a worker pool using:

icij-worker workers start "app.my_app"

provide worker pool options using:

icij-worker workers start -c worker_config.json -n 2 --backend multiprocessing "app.my_app"

depending on the worker configuration additional setup might be required.

Async worker implementations

Worker asynchronous backends

Implemented

To be implemented

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc