-
Notifications
You must be signed in to change notification settings - Fork 6
/
mwe.py
32 lines (24 loc) · 796 Bytes
/
mwe.py
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
27
28
29
30
31
32
import multiprocessing
import time
import sys
from lambda_multiprocessing import Pool as LambdaPool
import requests
def CreatePageWithWatermark(body: bytes, url):
time.sleep(1)
ret = (len(body), url)
print(f"Returning ({type(ret[0])}, {type(ret[1])})")
return ret
def PDFMergeWorker(event={}, context=None):
url='https://example.com/'
r = requests.get(url)
pages_data = [(
r.content,
url
) for _ in range(0,2)]
with LambdaPool() as executor:
rendered_pages = executor.starmap(CreatePageWithWatermark, pages_data)
expected_length = len(requests.get(url).content)
expected = [(expected_length, url) for _ in pages_data]
assert(rendered_pages == expected)
if __name__ == '__main__':
PDFMergeWorker()