當前位置: 首頁>>代碼示例>>Python>>正文


Python pycurl.E_CALL_MULTI_PERFORM屬性代碼示例

本文整理匯總了Python中pycurl.E_CALL_MULTI_PERFORM屬性的典型用法代碼示例。如果您正苦於以下問題:Python pycurl.E_CALL_MULTI_PERFORM屬性的具體用法?Python pycurl.E_CALL_MULTI_PERFORM怎麽用?Python pycurl.E_CALL_MULTI_PERFORM使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pycurl的用法示例。


在下文中一共展示了pycurl.E_CALL_MULTI_PERFORM屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _handle_events

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_events(self, fd, events):
        """Called by IOLoop when there is activity on one of our
        file descriptors.
        """
        action = 0
        if events & ioloop.IOLoop.READ:
            action |= pycurl.CSELECT_IN
        if events & ioloop.IOLoop.WRITE:
            action |= pycurl.CSELECT_OUT
        while True:
            try:
                ret, num_handles = self._multi.socket_action(fd, action)
            except pycurl.error as e:
                ret = e.args[0]
            if ret != pycurl.E_CALL_MULTI_PERFORM:
                break
        self._finish_pending_requests() 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:19,代碼來源:curl_httpclient.py

示例2: _handle_events

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_events(self, fd, events):
        """Called by IOLoop when there is activity on one of our
        file descriptors.
        """
        action = 0
        if events & ioloop.IOLoop.READ:
            action |= pycurl.CSELECT_IN
        if events & ioloop.IOLoop.WRITE:
            action |= pycurl.CSELECT_OUT
        while True:
            try:
                ret, num_handles = self._socket_action(fd, action)
            except pycurl.error as e:
                ret = e.args[0]
            if ret != pycurl.E_CALL_MULTI_PERFORM:
                break
        self._finish_pending_requests() 
開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:19,代碼來源:curl_httpclient.py

示例3: _handle_events

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_events(self, fd, events):
        """Called by IOLoop when there is activity on one of our
        file descriptors.
        """
        action = 0
        if events & ioloop.IOLoop.READ:
            action |= pycurl.CSELECT_IN
        if events & ioloop.IOLoop.WRITE:
            action |= pycurl.CSELECT_OUT
        while True:
            try:
                ret, num_handles = self._socket_action(fd, action)
            except pycurl.error, e:
                ret = e.args[0]
            if ret != pycurl.E_CALL_MULTI_PERFORM:
                break 
開發者ID:omererdem,項目名稱:honeything,代碼行數:18,代碼來源:curl_httpclient.py

示例4: _handle_timeout

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_timeout(self):
        """Called by IOLoop when the requested timeout has passed."""
        with stack_context.NullContext():
            self._timeout = None
            while True:
                try:
                    ret, num_handles = self._multi.socket_action(
                        pycurl.SOCKET_TIMEOUT, 0)
                except pycurl.error as e:
                    ret = e.args[0]
                if ret != pycurl.E_CALL_MULTI_PERFORM:
                    break
            self._finish_pending_requests()

        # In theory, we shouldn't have to do this because curl will
        # call _set_timeout whenever the timeout changes.  However,
        # sometimes after _handle_timeout we will need to reschedule
        # immediately even though nothing has changed from curl's
        # perspective.  This is because when socket_action is
        # called with SOCKET_TIMEOUT, libcurl decides internally which
        # timeouts need to be processed by using a monotonic clock
        # (where available) while tornado uses python's time.time()
        # to decide when timeouts have occurred.  When those clocks
        # disagree on elapsed time (as they will whenever there is an
        # NTP adjustment), tornado might call _handle_timeout before
        # libcurl is ready.  After each timeout, resync the scheduled
        # timeout with libcurl's current state.
        new_timeout = self._multi.timeout()
        if new_timeout >= 0:
            self._set_timeout(new_timeout) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:32,代碼來源:curl_httpclient.py

示例5: _handle_force_timeout

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_force_timeout(self):
        """Called by IOLoop periodically to ask libcurl to process any
        events it may have forgotten about.
        """
        with stack_context.NullContext():
            while True:
                try:
                    ret, num_handles = self._multi.socket_all()
                except pycurl.error as e:
                    ret = e.args[0]
                if ret != pycurl.E_CALL_MULTI_PERFORM:
                    break
            self._finish_pending_requests() 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:15,代碼來源:curl_httpclient.py

示例6: _handle_timeout

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_timeout(self):
        """Called by IOLoop when the requested timeout has passed."""
        with stack_context.NullContext():
            self._timeout = None
            while True:
                try:
                    ret, num_handles = self._socket_action(
                        pycurl.SOCKET_TIMEOUT, 0)
                except pycurl.error as e:
                    ret = e.args[0]
                if ret != pycurl.E_CALL_MULTI_PERFORM:
                    break
            self._finish_pending_requests()

        # In theory, we shouldn't have to do this because curl will
        # call _set_timeout whenever the timeout changes.  However,
        # sometimes after _handle_timeout we will need to reschedule
        # immediately even though nothing has changed from curl's
        # perspective.  This is because when socket_action is
        # called with SOCKET_TIMEOUT, libcurl decides internally which
        # timeouts need to be processed by using a monotonic clock
        # (where available) while tornado uses python's time.time()
        # to decide when timeouts have occurred.  When those clocks
        # disagree on elapsed time (as they will whenever there is an
        # NTP adjustment), tornado might call _handle_timeout before
        # libcurl is ready.  After each timeout, resync the scheduled
        # timeout with libcurl's current state.
        new_timeout = self._multi.timeout()
        if new_timeout >= 0:
            self._set_timeout(new_timeout) 
開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:32,代碼來源:curl_httpclient.py

示例7: _handle_timeout

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_timeout(self):
        """Called by IOLoop when the requested timeout has passed."""
        with stack_context.NullContext():
            self._timeout = None
            while True:
                try:
                    ret, num_handles = self._socket_action(
                        pycurl.SOCKET_TIMEOUT, 0)
                except pycurl.error, e:
                    ret = e.args[0]
                if ret != pycurl.E_CALL_MULTI_PERFORM:
                    break
            self._finish_pending_requests()

        # In theory, we shouldn't have to do this because curl will
        # call _set_timeout whenever the timeout changes.  However,
        # sometimes after _handle_timeout we will need to reschedule
        # immediately even though nothing has changed from curl's
        # perspective.  This is because when socket_action is
        # called with SOCKET_TIMEOUT, libcurl decides internally which
        # timeouts need to be processed by using a monotonic clock
        # (where available) while tornado uses python's time.time()
        # to decide when timeouts have occurred.  When those clocks
        # disagree on elapsed time (as they will whenever there is an
        # NTP adjustment), tornado might call _handle_timeout before
        # libcurl is ready.  After each timeout, resync the scheduled
        # timeout with libcurl's current state. 
開發者ID:omererdem,項目名稱:honeything,代碼行數:29,代碼來源:curl_httpclient.py

示例8: _handle_force_timeout

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_force_timeout(self):
        """Called by IOLoop periodically to ask libcurl to process any
        events it may have forgotten about.
        """
        with stack_context.NullContext():
            while True:
                try:
                    ret, num_handles = self._multi.socket_all()
                except pycurl.error, e:
                    ret = e.args[0]
                if ret != pycurl.E_CALL_MULTI_PERFORM:
                    break
            self._finish_pending_requests() 
開發者ID:omererdem,項目名稱:honeything,代碼行數:15,代碼來源:curl_httpclient.py

示例9: _handle_events

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_events(self, fd, events):
        """Called by IOLoop when there is activity on one of our
        file descriptors.
        """
        action = 0
        if events & ioloop.IOLoop.READ: action |= pycurl.CSELECT_IN
        if events & ioloop.IOLoop.WRITE: action |= pycurl.CSELECT_OUT
        while True:
            try:
                ret, num_handles = self._multi.socket_action(fd, action)
            except Exception, e:
                ret = e[0]
            if ret != pycurl.E_CALL_MULTI_PERFORM:
                break 
開發者ID:omererdem,項目名稱:honeything,代碼行數:16,代碼來源:httpclient.py

示例10: _handle_timeout

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _handle_timeout(self):
        """Called by IOLoop when the requested timeout has passed."""
        self._timeout = None
        while True:
            try:
                ret, num_handles = self._multi.socket_action(
                                        pycurl.SOCKET_TIMEOUT, 0)
            except Exception, e:
                ret = e[0]
            if ret != pycurl.E_CALL_MULTI_PERFORM:
                break 
開發者ID:omererdem,項目名稱:honeything,代碼行數:13,代碼來源:httpclient.py

示例11: _perform_on_curl

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _perform_on_curl(self):
        while True:
            ret, num_handles = self.curlmulti.perform()
            if ret != pycurl.E_CALL_MULTI_PERFORM:
                break
        return num_handles 
開發者ID:mesosphere,項目名稱:marathon-lb,代碼行數:8,代碼來源:utils.py

示例12: _read_multi_stack

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def _read_multi_stack(self):
        # Check for curl objects which have terminated, and add them to the curlh_freelist
        while not self.exit_job:
            while not self.exit_job:
                ret, num_handles = self.m.perform()
                if ret != pycurl.E_CALL_MULTI_PERFORM:
                    break

            num_q, ok_list, err_list = self.m.info_read()
            for curl_h in ok_list:
                self._process_curl_handle(curl_h)
                self.m.remove_handle(curl_h)
                self.curlh_freelist.append(curl_h)

            for curl_h, errno, errmsg in err_list:
                buff_body, buff_header, res, poolid = curl_h.response_queue

                if not self._process_curl_should_retry(res, errno, poolid):
                    self._process_curl_handle_error(res, errno, errmsg, poolid)

                self.m.remove_handle(curl_h)
                self.curlh_freelist.append(curl_h)

            while self.curlh_freelist and self._request_list:
                curl_h = self.curlh_freelist.pop()
                fuzzres, poolid = self._request_list.popleft()

                self.m.add_handle(
                    self._prepare_curl_h(curl_h, fuzzres, poolid)
                )

        self._stop_to_pools()

        # cleanup multi stack
        for c in self.handles:
            c.close()
            self.curlh_freelist.append(c)
        self.m.close() 
開發者ID:xmendez,項目名稱:wfuzz,代碼行數:40,代碼來源:myhttp.py

示例13: run

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def run(self):
        """Fetch events"""
        while 1:
            Ret, NumHandles = self.CurlMultiObj.perform()
            if Ret != pycurl.E_CALL_MULTI_PERFORM:
                break

        Ret = self.CurlMultiObj.select(1.0)
        while not self.stopped.isSet():
            # Sleeps to ease load on processor
            time.sleep(.05)
            Ret, NumHandles = self.CurlMultiObj.perform()

            if NumHandles != self.NumCurlObjs:
                _, Success, Error = self.CurlMultiObj.info_read()

                for CurlObj in Success:
                    DahuaDevice = next(filter(lambda x: x.CurlObj == CurlObj, self.Devices))
                    if DahuaDevice.Reconnect:
                        continue

                    DahuaDevice.OnDisconnect("Success")
                    DahuaDevice.Reconnect = time.time() + 5

                for CurlObj, ErrorNo, ErrorStr in Error:
                    DahuaDevice = next(filter(lambda x: x.CurlObj == CurlObj, self.Devices))
                    if DahuaDevice.Reconnect:
                        continue

                    DahuaDevice.OnDisconnect("{0} ({1})".format(ErrorStr, ErrorNo))
                    DahuaDevice.Reconnect = time.time() + 5

                for DahuaDevice in self.Devices:
                    if DahuaDevice.Reconnect and DahuaDevice.Reconnect < time.time():
                        self.CurlMultiObj.remove_handle(DahuaDevice.CurlObj)
                        self.CurlMultiObj.add_handle(DahuaDevice.CurlObj)
                        DahuaDevice.Reconnect = None
            #if Ret != pycurl.E_CALL_MULTI_PERFORM: break 
開發者ID:SaWey,項目名稱:home-assistant-dahua-event,代碼行數:40,代碼來源:dahua_event.py

示例14: perform

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def perform(self, logfile=None):
        """Fetch all of the added Request objects.

        Return two lists. The first list is a list of responses that
        completed. The second is list of the requests that errored.
        """
        m = pycurl.CurlMulti()
        requests = []
        num_q = num_urls = len(self._requests)
        reqs = self._requests
        self._requests = []
        for req in reqs:
            c, resp = req.get_requester()
            c.resp = resp
            m.add_handle(c)
            requests.append(c)
        del reqs

        while 1:
            ret, num_handles = m.perform()
            if ret != pycurl.E_CALL_MULTI_PERFORM:
                break

        num_handles = num_urls
        while num_handles:
            ret = m.select(5.0)
            if ret == -1:
                continue
            while 1:
                ret, num_handles = m.perform()
                if ret != pycurl.E_CALL_MULTI_PERFORM:
                    break

        goodlist = []
        errlist = []
        while 1:
            num_q, ok_list, err_list = m.info_read(num_urls)
            for c in ok_list:
                resp = c.resp
                del c.resp
                resp.error = None
                m.remove_handle(c)
                resp.finalize(c)
                goodlist.append(resp)
            for c, errno, errmsg in err_list:
                resp = c.resp
                del c.resp
                resp.error = (errno, errmsg)
                m.remove_handle(c)
                errlist.append(resp)
            if num_q == 0:
                break
        m.close()
        return goodlist, errlist 
開發者ID:kdart,項目名稱:pycopia,代碼行數:56,代碼來源:client.py

示例15: perform

# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import E_CALL_MULTI_PERFORM [as 別名]
def perform(cls):
        if cls._futures:
            while True:
                status, num_active = cls._multi.perform()
                if status != pycurl.E_CALL_MULTI_PERFORM:
                    break
            while True:
                num_ready, success, fail = cls._multi.info_read()
                for c in success:
                    cc = cls._futures.pop(c)
                    result = curl_result(c)
                    result['url'] = c._raw_url
                    result['id'] = c._raw_id
                    result['state'] = 'normal'
                    result['spider'] = 'pycurl'
                    result['payload'] = payload = c._raw_payload

                    # post_func = payload.get('post_func')
                    # if type(post_func) == str:
                    #     post_func = load(post_func)
                    # if post_func:
                    #     result = post_func(payload, result)

                    cc.set_result(result)
                for c, err_num, err_msg in fail:
                    print('error:', err_num, err_msg, c.getinfo(pycurl.EFFECTIVE_URL))
                    result = curl_result(c)

                    result['url'] = c._raw_url
                    result['id'] = c._raw_id
                    result['state'] = 'error'
                    result['spider'] = 'pycurl'
                    result['error_code'] = err_num
                    result['error_desc'] = err_msg

                    result['payload'] = payload = c._raw_payload

                    # post_func = payload.get('post_func')
                    # if type(post_func) == str:
                    #     post_func = load(post_func)
                    # if post_func:
                    #     result2 = post_func(payload, result)
                    #     if type(result2) is dict and len(result2) >= len(result):
                    #         result = result2
                    cls._futures.pop(c).set_exception(CurlLoop.CurlException(code=err_num, desc=err_msg, data=result))
                if num_ready == 0:
                    break 
開發者ID:pingf,項目名稱:falsy,代碼行數:49,代碼來源:curl_loop.py


注:本文中的pycurl.E_CALL_MULTI_PERFORM屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。