forked from lithops-cloud/lithops
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwait.py
More file actions
executable file
·26 lines (20 loc) · 736 Bytes
/
wait.py
File metadata and controls
executable file
·26 lines (20 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Simple Lithops example using rabbitmq to wait map function invocations
RabbitMQ amqp_url must be in configuration to make it working.
"""
import lithops
import time
total = 10
def my_function(x):
time.sleep(2)
return x + 7
if __name__ == "__main__":
fexec = lithops.FunctionExecutor(runtime_memory=256)
fexec.map(my_function, range(total))
fexec.wait() # blocks current execution until all function activations finish
fexec.clean()
# Activate RabbitMQ as a monitoring system
fexec = lithops.FunctionExecutor(runtime_memory=256, monitoring='rabbitmq')
fexec.map(my_function, range(total))
fexec.wait() # blocks current execution until all function activations finish
fexec.clean()