Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Support serverless environments #8061

Merged
merged 1 commit into from
Jul 17, 2023
Merged

Conversation

mr-brobot
Copy link
Contributor

@mr-brobot mr-brobot commented Jul 14, 2023

Relates to #8011 and #8015

Tested on macOS, Ubuntu, and in AWS Lambda. 😄

Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @mr-brobot, thanks for working on this!

➜  python git:(serverless) hyperfine --warmup 1 "python3 /tmp/benchmark.py"
Benchmark 1: python3 /tmp/vo.py
  Time (mean ± σ):      2.651 s ±  0.012 s    [User: 3.020 s, System: 1.844 s]
  Range (min … max):    2.637 s …  2.674 s    10 runs
 
➜  python git:(master) hyperfine --warmup 1 "python3 /tmp/benchmark.py"
Benchmark 1: python3 /tmp/vo.py
  Time (mean ± σ):      2.670 s ±  0.029 s    [User: 2.841 s, System: 1.934 s]
  Range (min … max):    2.610 s …  2.711 s    10 runs

func=_task_to_table,
iterable=[
for table in executor.map(
lambda args: _task_to_table(*args),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

# pylint: disable=redefined-outer-name,arguments-renamed,fixme
"""Concurrency concepts that support multi-threading."""
import threading
from concurrent.futures import Executor, ThreadPoolExecutor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mr-brobot Thanks for raising this. Just to config, as I understand it, AWS Lambda does not support multiprocessing, but concurrent.futures.* is okay?

Copy link
Contributor Author

@mr-brobot mr-brobot Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fokko Yes! multiprocessing appears to rely on shared memory throughout the module, even in ThreadPool. concurrent.futures.ThreadPoolExecutor is recommended since it was "designed around threads from the start" which also suggests that there are some MP concepts entangled with ThreadPool.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for the explanation 👍🏻

@Fokko Fokko merged commit fc89f0b into apache:master Jul 17, 2023
@Fokko
Copy link
Contributor

Fokko commented Jul 17, 2023

Thanks for fixing this @mr-brobot, and looking forward to your use-case using AWS Lambda's

@mr-brobot mr-brobot deleted the serverless branch July 17, 2023 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants