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