1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-23 03:02:50 +01:00

[oauth] workaround for ctrl+c on Windows

This commit is contained in:
Mike Fährmann 2017-06-14 15:27:16 +02:00
parent 9759fe8c6b
commit d60781de7b
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -10,6 +10,7 @@
from .common import Extractor, Message from .common import Extractor, Message
from . import reddit, flickr from . import reddit, flickr
import os
import time import time
import hmac import hmac
import base64 import base64
@ -73,7 +74,16 @@ class OAuthBase(Extractor):
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(("localhost", 6414)) server.bind(("localhost", 6414))
server.listen(1) server.listen(1)
self.client = server.accept()[0]
# workaround for ctrl+c not working during server.accept on Windows
if os.name == "nt":
server.settimeout(1.0)
while True:
try:
self.client = server.accept()[0]
break
except socket.timeout:
pass
server.close() server.close()
data = self.client.recv(1024).decode() data = self.client.recv(1024).decode()