mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
- rename LockFile.lock to acquire - rename LockFile.unlock to release - move the lockfile management in sepate functions inside the arbiter - remove the "closed" argument from the socket.close method and add a new "destroy" function that will be called whent the socket can be unlinked (cal release) - fix tests
28 lines
764 B
Python
28 lines
764 B
Python
try:
|
|
import unittest.mock as mock
|
|
except ImportError:
|
|
import mock
|
|
|
|
from gunicorn import sock
|
|
|
|
|
|
@mock.patch('os.getpid')
|
|
@mock.patch('os.unlink')
|
|
@mock.patch('socket.fromfd')
|
|
def test_unix_socket_close_delete_if_exlock(fromfd, unlink, getpid):
|
|
gsock = sock.UnixSocket('test.sock', mock.Mock(), mock.Mock(), mock.Mock())
|
|
gsock.destroy()
|
|
unlink.assert_called_with('test.sock')
|
|
|
|
|
|
@mock.patch('os.getpid')
|
|
@mock.patch('os.unlink')
|
|
@mock.patch('socket.fromfd')
|
|
def test_unix_socket_not_deleted_by_worker(fromfd, unlink, getpid):
|
|
fd = mock.Mock()
|
|
gsock = sock.UnixSocket('test.sock', mock.Mock(), mock.Mock(), fd)
|
|
getpid.reset_mock()
|
|
getpid.return_value = "fake" # fake a pid change
|
|
gsock.destroy()
|
|
unlink.assert_not_called()
|