Skip to content

Commit

Permalink
feat: added patch gunicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
akelch committed Sep 15, 2023
1 parent 941dd4f commit 1a503bf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

This file documents any relevant changes.
## [0.9.6] - 2023-09-15
- fix: updated grpcio to support python 3.11
- fix: gunicorn will be patched on start up


## [0.9.5] - 2023-09-14
- fix: updated werkzeug and gunicorn

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ install_requires =
pyyaml==6.0
gunicorn==21.2.0
fs==2.4.16
grpcio==1.44.0
grpcio==1.58.0

[options.packages.find]
where = src
Expand Down
19 changes: 17 additions & 2 deletions src/app_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@



__version__ = "0.9.5"
__version__ = "0.9.6"

subprocesses = []

Expand Down Expand Up @@ -253,6 +253,21 @@ def envVars(application_id, args):
if args.tasks:
os.environ["TASKS_EMULATOR"] = f"{args.host}:{args.tasks_port}"

def patch_gunicorn():
import gunicorn.workers.base
with open(gunicorn.workers.base.__file__, 'r+') as file:
content = file.read()

if "except (SyntaxError, NameError) as e:" in content:
return 0

file.seek(0)
file.write(content.replace(
' except SyntaxError as e:',
' except (SyntaxError, NameError) as e:'
))


def start_gunicorn(args, appYaml, appFolder, myFolder):
# Gunicorn call command
entrypoint = appYaml.get("entrypoint", "gunicorn -b :$PORT -w $WORKER --threads $THREADS "
Expand Down Expand Up @@ -307,7 +322,7 @@ def main():

args = ap.parse_args()
envVars(args.app_id, args)

patch_gunicorn()
myFolder = os.getcwd()
appFolder = os.path.abspath(args.config_paths[0])

Expand Down

1 comment on commit 1a503bf

@sveneberth
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 👍

Please sign in to comment.