Skip to content

Python3 process pool for environments without semaphore support

License

Notifications You must be signed in to change notification settings

georgepsarakis/lambda-pond

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lambda-pond

A Process Pool for environments where semaphore support is unavailable (sem_open and sem_init), such as AWS Lambda.

Features

  • Task Timeout
  • Worker recycling after a certain amount of processed tasks
  • TODO: Memory monitoring
  • TODO: batch / map functionality

Examples

import hashlib

from lambda_pond import Pool

def f(x):
    return hashlib.sha1(('h' * (x + 1) * 10**8).encode()).hexdigest()        

with Pool(task_timeout=2) as p:
    tasks = []
    for n in range(10):
        t = p.apply_async(f, n)
        tasks.append(t)

for task in tasks:
    print(task.identifier, '->', task.result) 

References

Credits

  • API and multithreaded design using Queues inspired by the standard library multiprocessing.Pool.
  • Worker pool concepts (timeout) inspired by Celery.

About

Python3 process pool for environments without semaphore support

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages