Explicitly close UDP sockets when re-creating them.
This does not actually make a big difference since the GC should technically close them when needed but might as well be more explicit.
This commit is contained in:
parent
fac43ad595
commit
663315f7ac
@ -94,6 +94,7 @@ class VoiceClient:
|
|||||||
self.main_ws = None
|
self.main_ws = None
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self.ws = None
|
self.ws = None
|
||||||
|
self.socket = None
|
||||||
self.loop = state.loop
|
self.loop = state.loop
|
||||||
self._state = state
|
self._state = state
|
||||||
# this will be used in the AudioPlayer thread
|
# this will be used in the AudioPlayer thread
|
||||||
@ -174,6 +175,13 @@ class VoiceClient:
|
|||||||
|
|
||||||
self.endpoint = endpoint.replace(':80', '')
|
self.endpoint = endpoint.replace(':80', '')
|
||||||
self.endpoint_ip = socket.gethostbyname(self.endpoint)
|
self.endpoint_ip = socket.gethostbyname(self.endpoint)
|
||||||
|
|
||||||
|
if self.socket:
|
||||||
|
try:
|
||||||
|
self.socket.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
self.socket.setblocking(False)
|
self.socket.setblocking(False)
|
||||||
|
|
||||||
@ -254,6 +262,7 @@ class VoiceClient:
|
|||||||
yield from self.ws.close()
|
yield from self.ws.close()
|
||||||
yield from self.terminate_handshake(remove=True)
|
yield from self.terminate_handshake(remove=True)
|
||||||
finally:
|
finally:
|
||||||
|
if self.socket:
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
Loading…
x
Reference in New Issue
Block a user