本文整理汇总了Python中miro.clock.clock函数的典型用法代码示例。如果您正苦于以下问题:Python clock函数的具体用法?Python clock怎么用?Python clock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: onReadTimeout
def onReadTimeout(self):
if self.readSomeData:
timeout = SOCKET_READ_TIMEOUT
else:
timeout = SOCKET_INITIAL_READ_TIMEOUT
if clock() < self.lastClock + timeout:
self.readTimeout = eventloop.add_timeout(self.lastClock + timeout - clock(), self.onReadTimeout,
"AsyncSocket.onReadTimeout")
else:
self.readTimeout = None
self.timedOut = True
self.handleEarlyClose('read')
开发者ID:cool-RR,项目名称:Miro,代码行数:13,代码来源:net.py
示例2: check_subprocess_hung
def check_subprocess_hung(self):
task_status = self.responder.movie_data_task_status
logging.warn("check_subprocess_hung: %s (time: %s)", task_status,
clock.clock())
if (task_status is not None and
clock.clock() - task_status.start_time > 90):
logging.warn("Worker process is hanging on a movie data task.")
error_result = TaskResult(task_status.task_id,
SubprocessTimeoutError())
self.responder.handle_task_result(error_result)
self.restart()
else:
self.schedule_check_subprocess_hung()
开发者ID:bbucommander,项目名称:miro,代码行数:14,代码来源:workerprocess.py
示例3: __init__
def __init__(self, url=None, item=None, restore=None):
self.metainfo = None
self.torrent = None
self.rate = self.eta = 0
self.upRate = self.uploaded = 0
self.activity = None
self.fastResumeData = None
self.retryDC = None
self.channelName = None
self.uploadedStart = 0
self.restarting = False
self.seeders = -1
self.leechers = -1
self.last_fast_resume_update = clock()
self.metainfo_updated = self.fast_resume_data_updated = False
if restore is not None:
self.firstTime = False
self.restore_state(restore)
else:
self.firstTime = True
BGDownloader.__init__(self, url, item)
self.run_downloader()
self.item = item
self._last_reannounce_time = time.time()
开发者ID:nxmirrors,项目名称:miro,代码行数:25,代码来源:download.py
示例4: startReadTimeout
def startReadTimeout(self):
if self.disable_read_timeout:
return
self.lastClock = clock()
if self.readTimeout is not None:
return
self.readTimeout = eventloop.add_timeout(SOCKET_INITIAL_READ_TIMEOUT, self.onReadTimeout,
"AsyncSocket.onReadTimeout")
开发者ID:cool-RR,项目名称:Miro,代码行数:8,代码来源:net.py
示例5: add_timeout
def add_timeout(self, delay, function, name, args=None, kwargs=None):
if args is None:
args = ()
if kwargs is None:
kwargs = {}
scheduled_time = clock() + delay
dc = DelayedCall(function, "timeout (%s)" % (name,), args, kwargs)
heapq.heappush(self.heap, (scheduled_time, dc))
return dc
开发者ID:codito,项目名称:miro,代码行数:9,代码来源:eventloop.py
示例6: do_mythtv_update_autodownload
def do_mythtv_update_autodownload(self, line):
"""Update feeds and auto-download"""
logging.info("Starting auto downloader...")
autodler.start_downloader()
feed.expire_items()
starttime = clock()
logging.timing("Icon clear: %.3f", clock() - starttime)
logging.info("Starting video updates")
moviedata.movieDataUpdater.startThread()
parse_command_line_args()
# autoupdate.check_for_updates()
# Wait a bit before starting the downloader daemon. It can cause a bunch
# of disk/CPU load, so try to avoid it slowing other stuff down.
eventloop.addTimeout(5, downloader.startupDownloader,
"start downloader daemon")
# ditto for feed updates
eventloop.addTimeout(30, feed.start_updates, "start feed updates")
# ditto for clearing stale icon cache files, except it's the very lowest
# priority
eventloop.addTimeout(10, iconcache.clear_orphans, "clear orphans")
开发者ID:JackOfMostTrades,项目名称:mythtv,代码行数:20,代码来源:mirobridge_interpreter_2_0_3.py
示例7: _start_subprocess
def _start_subprocess(self):
cmd_line, env = utils.miro_helper_program_info()
kwargs = {
"stdout": subprocess.PIPE,
"stdin": subprocess.PIPE,
"stderr": open(os.devnull, 'wb'),
"env": env,
"close_fds": True
}
process = Popen(cmd_line, **kwargs)
self.start_time = clock.clock()
return process
开发者ID:ShriramK,项目名称:miro,代码行数:12,代码来源:subprocessmanager.py
示例8: _on_thread_quit
def _on_thread_quit(self, thread):
"""Handle our thread exiting."""
# Ignore this call if it was queued from while we were in the middle
# of shutdown().
if not self.is_running:
return
if thread is not self.thread:
# If we have lost the race between the cleanup on shutdown
# it should be safe to ignore.
#
# This can happen when the process does not immediately shut down
# because the worker process is still processing pending jobs
# and the quit message was not processed in time and so the
# subprocess was forcibly terminated. When that happens
# _cleanup_process() is called which resets the thread attribute
# to None immediately, but _on_thread_quit() is only run some
# time after that (when we notice the pipe to the subprocess's
# close we add _on_thread_quit() to the idle loop).
#
# So if the self.thread attribute is None then it means we are done
# and so things are all good.
if self.thread is not None and thread.quit_type != thread.QUIT_NORMAL:
msg = ('_on_thread_quit called by an old thread '
'self.thread: %s thread: %s quit_type: %s' %
(self.thread.name, thread.name, thread.quit_type))
app.controller.failed_soft('handling subprocess', msg)
return
if (self.thread.quit_type == self.thread.QUIT_NORMAL and
self.sent_quit):
self._cleanup_process()
else:
logging.warn("Subprocess quit unexpectedly (quit_type: %s, "
"sent_quit: %s). Will restart subprocess",
self.thread.quit_type, self.sent_quit)
# NOTE: should we enforce some sort of cool-down time before
# restarting the subprocess?
time_since_start = clock.clock() - self.start_time
delay_time = self.restart_delay - time_since_start
if delay_time <= 0:
logging.warn("Subprocess died after %0.1f seconds. "
"Restarting", time_since_start)
self.restart()
else:
logging.warn("Subprocess died in %0.1f seconds, waiting "
"%0.1f to restart", time_since_start, delay_time)
eventloop.add_timeout(delay_time, self.restart,
'restart failed subprocess')
开发者ID:ShriramK,项目名称:miro,代码行数:50,代码来源:subprocessmanager.py
示例9: update_status
def update_status(self):
"""
activity -- string specifying what's currently happening or None for
normal operations.
upRate -- upload rate in B/s
downRate -- download rate in B/s
upTotal -- total MB uploaded
downTotal -- total MB downloaded
fractionDone -- what portion of the download is completed.
timeEst -- estimated completion time, in seconds.
totalSize -- total size of the torrent in bytes
"""
status = self.torrent.status()
self.totalSize = status.total_wanted
self.rate = status.download_payload_rate
self.upRate = status.upload_payload_rate
self.uploaded = status.total_payload_upload + self.uploadedStart
self.seeders = status.num_complete
self.leechers = status.num_incomplete
try:
self.eta = ((status.total_wanted - status.total_wanted_done) /
float(status.download_payload_rate))
except ZeroDivisionError:
self.eta = 0
if status.state == lt.torrent_status.states.queued_for_checking:
self.activity = "waiting to check existing files"
elif status.state == lt.torrent_status.states.checking_files:
self.activity = "checking existing files"
elif status.state == lt.torrent_status.states.allocating:
self.activity = "allocating disk space"
else:
self.activity = None
self.currentSize = status.total_wanted_done
if ((self.state == "downloading"
and status.state == lt.torrent_status.states.seeding)):
self.move_to_movies_directory()
self.state = "uploading"
self.endTime = clock()
self.update_client()
else:
DOWNLOAD_UPDATER.queue_update(self)
if app.config.get(prefs.LIMIT_UPLOAD_RATIO):
if status.state == lt.torrent_status.states.seeding:
if ((float(self.uploaded) / self.totalSize >
app.config.get(prefs.UPLOAD_RATIO))):
self.stop_upload()
if self.should_update_fast_resume_data():
self.update_fast_resume_data()
开发者ID:cool-RR,项目名称:Miro,代码行数:50,代码来源:download.py
示例10: time_trap_call
def time_trap_call(when, function, *args, **kwargs):
global cancel
cancel = False
start = clock()
retval = trap_call(when, function, *args, **kwargs)
end = clock()
if cancel:
return retval
if end-start > 1.0:
logging.timing("WARNING: %s too slow (%.3f secs)", when, end-start)
if TRACK_CUMULATIVE:
try:
total = cumulative[when]
except KeyError:
total = 0
total += end - start
cumulative[when] = total
if total > 5.0:
logging.timing("%s cumulative is too slow (%.3f secs)", when, total)
cumulative[when] = 0
return retval
cancel = True
return retval
开发者ID:cool-RR,项目名称:Miro,代码行数:23,代码来源:trapcall.py
示例11: dispatch
def dispatch(self):
success = True
if not self.canceled:
when = "While handling %s" % self.name
start = clock()
success = trapcall.trap_call(when, self.function, *self.args,
**self.kwargs)
end = clock()
if end-start > 0.5:
logging.timing("%s too slow (%.3f secs)",
self.name, end-start)
try:
total = cumulative[self.name]
except (KeyError, AttributeError):
total = 0
total += end - start
cumulative[self.name] = total
if total > 5.0:
logging.timing("%s cumulative is too slow (%.3f secs)",
self.name, total)
cumulative[self.name] = 0
self._unlink()
return success
开发者ID:codito,项目名称:miro,代码行数:23,代码来源:eventloop.py
示例12: on_download_finished
def on_download_finished(self, response):
self.destroy_client()
self.state = "finished"
self.endTime = clock()
# bug 14131 -- if there's nothing here, treat it like a temporary
# error
if self.currentSize == 0:
self.handle_network_error(httpclient.PossiblyTemporaryError(_("no content")))
else:
if self.totalSize == -1:
self.totalSize = self.currentSize
try:
self.move_to_movies_directory()
except IOError, e:
self.handle_write_error(e)
开发者ID:nxmirrors,项目名称:miro,代码行数:16,代码来源:download.py
示例13: next_timeout
def next_timeout(self):
if len(self.heap) == 0:
return None
else:
return max(0, self.heap[0][0] - clock())
开发者ID:codito,项目名称:miro,代码行数:5,代码来源:eventloop.py
示例14: update_fast_resume_data
def update_fast_resume_data(self):
self.last_fast_resume_update = clock()
self.fastResumeData = lt.bencode(self.torrent.write_resume_data())
self.fast_resume_data_updated = True
开发者ID:nxmirrors,项目名称:miro,代码行数:4,代码来源:download.py
示例15: log_total_time
def log_total_time(self):
logging.timing("total time: %0.3f", clock() - self.start_time)
开发者ID:foxi,项目名称:miro,代码行数:2,代码来源:util.py
示例16: log_time
def log_time(self, msg):
current_time = clock()
logging.timing("%s: %0.4f", msg, current_time - self.last_time)
self.last_time = current_time
开发者ID:foxi,项目名称:miro,代码行数:4,代码来源:util.py
示例17: __init__
def __init__(self):
self.start_time = self.last_time = clock()
开发者ID:foxi,项目名称:miro,代码行数:2,代码来源:util.py
示例18: handle_movie_data_task_status
def handle_movie_data_task_status(self, msg):
if msg.task_id is not None:
self.movie_data_task_status = MovieDataTaskStatusInfo(
msg.task_id, clock.clock())
else:
self.movie_data_task_status = None
开发者ID:adarshr,项目名称:miro,代码行数:6,代码来源:workerprocess.py
示例19: has_pending_timeout
def has_pending_timeout(self):
return len(self.heap) > 0 and self.heap[0][0] < clock()
开发者ID:codito,项目名称:miro,代码行数:2,代码来源:eventloop.py
示例20: should_update_fast_resume_data
def should_update_fast_resume_data(self):
return (clock() - self.last_fast_resume_update >
self.FAST_RESUME_UPDATE_INTERVAL)
开发者ID:nxmirrors,项目名称:miro,代码行数:3,代码来源:download.py
注:本文中的miro.clock.clock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论