Skip to content

Commit

Permalink
Compatible with Python3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
aisk committed Jul 3, 2024
1 parent f5f7b0d commit 4e78254
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions thriftpy2/contrib/aio/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

from __future__ import absolute_import, division

import ssl
import asyncio
import errno
import os
import socket
import ssl
import struct
import sys
if sys.version_info >= (3, 7, 0):
from asyncio import get_running_loop
else:
from asyncio import _get_running_loop as get_running_loop

from thriftpy2.transport import TTransportException
from thriftpy2.transport._ssl import (
Expand All @@ -17,6 +21,7 @@
DEFAULT_CIPHERS
)


MAC_OR_BSD = sys.platform == 'darwin' or sys.platform.startswith('freebsd')


Expand Down Expand Up @@ -145,7 +150,7 @@ async def open(self):
if self.connect_timeout:
self.raw_sock.settimeout(self.connect_timeout)

loop = asyncio.get_running_loop()
loop = get_running_loop()
# The raw_sock.connect may block the event loop if the target
# server is slow or unreachable. Using a thread pool to solve it
# as a quick and dirty way. See #270.
Expand Down

0 comments on commit 4e78254

Please sign in to comment.