本文整理汇总了Python中tornado.log.gen_log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
def update(self, obj, callback=None):
"""
Updates the value for a key atomically. Typical usage would be:
c = etcd.Client()
o = c.read("/somekey")
o.value += 1
c.update(o)
Args:
obj (etcd.EtcdResult): The object that needs updating.
"""
assert isinstance(obj, EtcdResult), "obj not a EtcdResult."
_log.debug("Updating %s to %s.", obj.key, obj.value)
kwdargs = {
'dir': obj.dir,
'ttl': obj.ttl,
'prevExist': True
}
if not obj.dir:
# prevIndex on a dir causes a 'not a file' error. d'oh!
kwdargs['prevIndex'] = obj.modifiedIndex
return self.write(obj.key, obj.value, callback=callback, **kwdargs)
示例2: watch
def watch(self, key, index=None, timeout=None, recursive=None, callback=None):
# todo
"""
Blocks until a new event has been received, starting at index 'index'
Args:
key (str): Key.
index (int): Index to start from.
timeout (int): max seconds to wait for a read.
Returns:
client.EtcdResult
Raises:
KeyValue: If the key doesn't exists.
urllib3.exceptions.TimeoutError: If timeout is reached.
>>> print client.watch('/key').value
'value'
"""
_log.debug("About to wait on key %s, index %s", key, index)
if index:
return self.read(key, wait=True, waitIndex=index, timeout=timeout,
recursive=recursive, callback=callback)
else:
return self.read(key, wait=True, timeout=timeout,
recursive=recursive, callback=callback)
示例3: _callback
def _callback(fut):
exc = fut.exc_info()
if exc:
if not isinstance(exc[1], etcdexcept.EtcdException):
# We can't get the list of machines, if one server is in the
# machines cache, try on it
_log.error("Failed to get list of machines from %s%s: %r and retry it.",
uri, self.version_prefix, exc)
if self._machines_cache:
self._base_url = self._machines_cache.pop(0)
_log.debug("Retrying on %s", self._base_url)
# Call myself
self.ioloop.add_future(self.search_machine(), _callback)
return
else:
raise etcdexcept.EtcdException("Could not get the list of servers, "
"maybe you provided the wrong "
"host(s) to connect to?")
else:
response = fut.result()
machines = [
node.strip() for node in
self._handle_server_response(response).body.decode('utf-8').split(',')
]
_log.debug("Retrieved list of machines: %s", machines)
self._machines_cache = machines
if self._base_url not in self._machines_cache:
self._base_url = self._choice_machine()
callback(fut.result())
示例4: _on_content_headers
def _on_content_headers(self, data, buf=b""):
self._content_length_left -= len(data)
data = self._boundary_buffer + data
gen_log.debug("file header is %r", data)
self._boundary_buffer = buf
header_data = data[self._boundary_len + 2 :].decode("utf-8")
headers = tornado.httputil.HTTPHeaders.parse(header_data)
disp_header = headers.get("Content-Disposition", "")
disposition, disp_params = tornado.httputil._parse_header(disp_header)
if disposition != "form-data":
gen_log.warning("Invalid multipart/form-data")
self._read_content_body(None)
if not disp_params.get("name"):
gen_log.warning("multipart/form-data value missing name")
self._read_content_body(None)
name = disp_params["name"]
if disp_params.get("filename"):
ctype = headers.get("Content-Type", "application/unknown")
fd, tmp_filename = tempfile.mkstemp(suffix=".tmp", prefix="tornado")
self._request.files.setdefault(name, []).append(
tornado.httputil.HTTPFile(
filename=disp_params["filename"], tmp_filename=tmp_filename, content_type=ctype
)
)
self._read_content_body(os.fdopen(fd, "wb"))
else:
gen_log.warning("multipart/form-data is not file upload, skipping...")
self._read_content_body(None)
示例5: process_message
def process_message(self, client, msg):
try:
gen_log.debug("Received from WS: %s" % msg)
msg = json.loads(msg)
except ValueError:
gen_log.warning("Received message not in json from client %s: %s"
% (client.remote_address, msg))
return
try:
service_name = msg['service']
except KeyError:
gen_log.warning("Malformed message from client %s: %s"
% (client.remote_address, msg))
return
try:
service = self.services[service_name]
except KeyError:
gen_log.warning(
'Message for non existing service "%s" from client %s'
% (service_name, client.remote_address))
return
service.process_message(client, msg)
示例6: close
def close(self, all_fds=False):
"""Closes the IOLoop, freeing any resources used.
If ``all_fds`` is true, all file descriptors registered on the
IOLoop will be closed (not just the ones created by the IOLoop itself).
Many applications will only use a single IOLoop that runs for the
entire lifetime of the process. In that case closing the IOLoop
is not necessary since everything will be cleaned up when the
process exits. `IOLoop.close` is provided mainly for scenarios
such as unit tests, which create and destroy a large number of
IOLoops.
An IOLoop must be completely stopped before it can be closed. This
means that `IOLoop.stop()` must be called *and* `IOLoop.start()` must
be allowed to return before attempting to call `IOLoop.close()`.
Therefore the call to `close` will usually appear just after
the call to `start` rather than near the call to `stop`.
"""
self.remove_handler(self._waker.fileno())
if all_fds:
for fd in self._handlers.keys()[:]:
try:
os.close(fd)
except Exception:
gen_log.debug("error closing fd %s", fd, exc_info=True)
self._waker.close()
self._impl.close()
示例7: fetch_impl
def fetch_impl(self, request, callback):
self.queue.append((request, callback))
self._process_queue()
if self.queue:
gen_log.debug("max_clients limit reached, request queued. "
"%d active, %d queued requests." % (
len(self.active), len(self.queue)))
示例8: init_mysql_pool
def init_mysql_pool(self, jdbc_url, max_connections=10, idle_seconds=60, wait_connection_timeout=3):
"""
:param jdbc_url: mysql://root:[email protected]:3306/mysql
:return:
"""
if not jdbc_url:
return
gen_log.debug("jdbc_url: %s", jdbc_url)
conf = urlparse.urlparse(jdbc_url)
gen_log.debug("hostname: %s, db: %s, user: %s, passwd: %s, port: %s",
conf.hostname, conf.path, conf.username, conf.password, conf.port)
db = ''
if len(conf.path) > 1:
db = conf.path[1:]
return tormysql.ConnectionPool(
max_connections=int(max_connections), # max open connections
idle_seconds=int(idle_seconds), # conntion idle timeout time, 0 is not timeout
wait_connection_timeout=int(wait_connection_timeout), # wait connection timeout
host=conf.hostname,
user=conf.username,
passwd=conf.password,
db=db,
charset="utf8"
)
示例9: remove_handler
def remove_handler(self, fd):
self._handlers.pop(fd, None)
self._events.pop(fd, None)
try:
self._impl.unregister(fd)
except Exception:
gen_log.debug("Error deleting fd from IOLoop", exc_info=True)
示例10: remove_handler
def remove_handler(self, fd):
"""Stop listening for events on fd."""
self._handlers.pop(fd, None)
self._events.pop(fd, None)
try:
self._impl.unregister(fd)
except (OSError, IOError):
gen_log.debug("Error deleting fd from IOLoop", exc_info=True)
示例11: accept_connection
def accept_connection(self):
try:
self._handle_websocket_headers()
self._accept_connection()
except ValueError:
gen_log.debug("Malformed WebSocket request received", exc_info=True)
self._abort()
return
示例12: enable_errors
def enable_errors(self):
"""
Alias for adding the error interest from the event handler.
"""
if _SHOULD_LOG_DEBUG_OUTPUT:
gen_log.debug('Resuming error events for stream(fd:{})'.format(
self.fileno))
self._add_event_interest(ERROR)
示例13: disable_errors
def disable_errors(self):
"""
Alias for removing the error interest from the event handler.
"""
if _SHOULD_LOG_DEBUG_OUTPUT:
gen_log.debug('Halting error events for stream(fd:{})'.format(
self.fileno))
self._drop_event_interest(ERROR)
示例14: disable_reading
def disable_reading(self):
"""
Alias for removing the read interest from the event handler.
"""
if _SHOULD_LOG_DEBUG_OUTPUT:
gen_log.debug('Halting read events for stream(fd:{})'.format(
self.fd))
self._drop_event_interest(self._io_loop.READ)
示例15: enable_writes
def enable_writes(self):
"""
Alias for adding the send interest to the event handler.
"""
if _SHOULD_LOG_DEBUG_OUTPUT:
gen_log.debug('Resuming write events for stream(fd:{})'.format(
self.fileno))
self._add_event_interest(WRITE)