Skip to content

Commit

Permalink
fix python runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
pfandzelter committed May 13, 2024
1 parent fb807f0 commit 1e37e2c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
44 changes: 41 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ manager
rproxy
tmp/

# Created by https://www.toptal.com/developers/gitignore/api/python,node,go,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=python,node,go,visualstudiocode
# Created by https://www.toptal.com/developers/gitignore/api/go,node,python,visualstudiocode,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=go,node,python,visualstudiocode,macos

### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
Expand All @@ -28,6 +28,39 @@ tmp/
# Go workspace file
go.work

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Node ###
# Logs
logs
Expand Down Expand Up @@ -330,6 +363,11 @@ cython_debug/
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml

# ruff
.ruff_cache/

# LSP config files
pyrightconfig.json

### VisualStudioCode ###
.vscode/*
Expand All @@ -350,4 +388,4 @@ poetry.toml
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/python,node,go,visualstudiocode
# End of https://www.toptal.com/developers/gitignore/api/go,node,python,visualstudiocode,macos
1 change: 1 addition & 0 deletions runtimes/python3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ COPY . .
RUN mv fn/* .
RUN python -m pip install -r requirements.txt --user

ENV PYTHONUNBUFFERED=1
CMD [ "python3", "functionhandler.py" ]
6 changes: 4 additions & 2 deletions runtimes/python3/functionhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def do_GET(self) -> None:
return

def do_POST(self) -> None:
d: typing.Optional[str] = self.rfile.read(int(self.headers["Content-Length"])).decode("utf-8")
d: typing.Optional[str] = self.rfile.read(
int(self.headers["Content-Length"])
).decode("utf-8")
if d == "":
d = None

Expand All @@ -43,5 +45,5 @@ def do_POST(self) -> None:
self.wfile.write(str(e).encode("utf-8"))
return

with socketserver.TCPServer(("", 8000), tinyFaaSFNHandler) as httpd:
with socketserver.ThreadingTCPServer(("", 8000), tinyFaaSFNHandler) as httpd:
httpd.serve_forever()

0 comments on commit 1e37e2c

Please sign in to comment.