@@ -65,15 +65,6 @@ def initialize( # type: ignore
6565 self ._fds = {} # type: Dict[int, int]
6666 self ._timeout = None # type: Optional[object]
6767
68- # libcurl has bugs that sometimes cause it to not report all
69- # relevant file descriptors and timeouts to TIMERFUNCTION/
70- # SOCKETFUNCTION. Mitigate the effects of such bugs by
71- # forcing a periodic scan of all active requests.
72- self ._force_timeout_callback = ioloop .PeriodicCallback (
73- self ._handle_force_timeout , 1000
74- )
75- self ._force_timeout_callback .start ()
76-
7768 # Work around a bug in libcurl 7.29.0: Some fields in the curl
7869 # multi object are initialized lazily, and its destructor will
7970 # segfault if it is destroyed without having been used. Add
@@ -84,7 +75,6 @@ def initialize( # type: ignore
8475 self ._multi .remove_handle (dummy_curl_handle )
8576
8677 def close (self ) -> None :
87- self ._force_timeout_callback .stop ()
8878 if self ._timeout is not None :
8979 self .io_loop .remove_timeout (self ._timeout )
9080 for curl in self ._curls :
@@ -95,7 +85,6 @@ def close(self) -> None:
9585 # Set below properties to None to reduce the reference count of current
9686 # instance, because those properties hold some methods of current
9787 # instance that will case circular reference.
98- self ._force_timeout_callback = None # type: ignore
9988 self ._multi = None
10089
10190 def fetch_impl (
@@ -189,19 +178,6 @@ def _handle_timeout(self) -> None:
189178 if new_timeout >= 0 :
190179 self ._set_timeout (new_timeout )
191180
192- def _handle_force_timeout (self ) -> None :
193- """Called by IOLoop periodically to ask libcurl to process any
194- events it may have forgotten about.
195- """
196- while True :
197- try :
198- ret , num_handles = self ._multi .socket_all ()
199- except pycurl .error as e :
200- ret = e .args [0 ]
201- if ret != pycurl .E_CALL_MULTI_PERFORM :
202- break
203- self ._finish_pending_requests ()
204-
205181 def _finish_pending_requests (self ) -> None :
206182 """Process any requests that were completed by the last
207183 call to multi.socket_action.
@@ -484,12 +460,12 @@ def write_function(b: Union[bytes, bytearray]) -> int:
484460 raise ValueError ("Body must be None for GET request" )
485461 request_buffer = BytesIO (utf8 (request .body or "" ))
486462
487- def ioctl ( cmd : int ) -> None :
488- if cmd == curl . IOCMD_RESTARTREAD : # type: ignore
489- request_buffer . seek ( 0 )
463+ def seek ( offset : int , origin : int ) -> int :
464+ request_buffer . seek ( offset , origin )
465+ return pycurl . SEEKFUNC_OK
490466
491467 curl .setopt (pycurl .READFUNCTION , request_buffer .read )
492- curl .setopt (pycurl .IOCTLFUNCTION , ioctl )
468+ curl .setopt (pycurl .SEEKFUNCTION , seek )
493469 if request .method == "POST" :
494470 curl .setopt (pycurl .POSTFIELDSIZE , len (request .body or "" ))
495471 else :
0 commit comments