mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-07 21:21:30 +08:00
Merge pull request #3522 from bysiber/fix-sd-notify-unbound-error
fix: prevent UnboundLocalError in sd_notify when socket creation fails
This commit is contained in:
commit
32e46a58ce
@ -61,6 +61,7 @@ def sd_notify(state, logger, unset_environment=False):
|
|||||||
if addr is None:
|
if addr is None:
|
||||||
# not run in a service, just a noop
|
# not run in a service, just a noop
|
||||||
return
|
return
|
||||||
|
sock = None
|
||||||
try:
|
try:
|
||||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM | socket.SOCK_CLOEXEC)
|
sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM | socket.SOCK_CLOEXEC)
|
||||||
if addr[0] == '@':
|
if addr[0] == '@':
|
||||||
@ -72,4 +73,5 @@ def sd_notify(state, logger, unset_environment=False):
|
|||||||
finally:
|
finally:
|
||||||
if unset_environment:
|
if unset_environment:
|
||||||
os.environ.pop('NOTIFY_SOCKET')
|
os.environ.pop('NOTIFY_SOCKET')
|
||||||
|
if sock is not None:
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user