sachin-sankar / swiftshadow

Free IP Proxy rotator library for python
https://sachin-sankar.github.io/swiftshadow/
GNU General Public License v3.0
72 stars 5 forks source link

Lambda on aws unable to proceed due to Read-only file system #17

Closed julianCast closed 1 year ago

julianCast commented 1 year ago

Hi! On my local environment works fine, but when I try to run it on my lambda I get this

Function Logs
START RequestId: 5ea8d3a7-8f08-4f9b-b9c0-10a6c3c94cc7 Version: $LATEST
07/05/2023 20:35:43 - [swiftshadow] - ERROR : No cache found. Cache will be created after update
07/05/2023 20:35:43 - [swiftshadow] - INFO : Updating proxies from Proxyscrape
[ERROR] OSError: [Errno 30] Read-only file system: '.swiftshadow.json'
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 13, in lambda_handler
    swift = Proxy()
  File "/opt/python/swiftshadow/swiftshadow.py", line 49, in __init__
    self.update()
  File "/opt/python/swiftshadow/swiftshadow.py", line 100, in update
    with open(".swiftshadow.json", "w") as file:END RequestId: 5ea8d3a7-8f08-4f9b-b9c0-10a6c3c94cc7
REPORT RequestId: 5ea8d3a7-8f08-4f9b-b9c0-10a6c3c94cc7  Duration: 6597.86 ms    Billed Duration: 6598 ms    Memory Size: 128 MB Max Memory Used: 65 MB  Init Duration: 813.64 ms

According to stackoverflow:

Only /tmp seems to be writable in AWS Lambda. Is there a way to pass a folder path to your library instance?

julianCast commented 1 year ago

I'm currently modifying this https://github.com/search?q=repo%3Asachin-sankar%2Fswiftshadow%20swiftshadow.json&type=code to "/tmp/swiftshadow.json", that makes it compatible with lambda. If you want me to make a PR, let me know!

sachin-sankar commented 1 year ago

Hey @julianCast thanks for sharing the bug. I will implement the changes myself as I am currently working on v1.0.0 with some huge changes.