per page, with , order by , clip by
Results of 1 - 10 of about 40 for sleep (0.003 sec.)
キュー 12669
キュー ソースコード: Lib/asyncio/queues.py asyncio キューは queue モジュールのクラス群と同じ形になるように設計されています。 asyncio キューはスレッドセーフではありませんが、それらは async/await コードから使われるために特別に設計されています ... import asyncio import random import time async def worker ( name , queue ): while True : # キューから作業項目を取り出す。 sleep_for = await queue . get () # sleep_for 秒スリープする。 await asyncio . sleep ( sleep_for ) # 作業項目の処理が完了したこと ... をキューに通知する。 queue . task_done () print ( f ' { name } has slept for { sleep_for : .2f } seconds' ) async def main (): # 作業を格納するキューを作成する。 queue = asyncio . Queue () # ランダムな待ち時 ... 間を生成してキューに追加する。 total_sleep_time = 0 for _ in range ( 20 ): sleep_for = random . uniform ( 0.05 , 1.0 ) total_sleep_time += sleep_for queue . put_nowa ...
https://man.mtool.work/python/3.14/library/asyncio-queue.html
A Conceptual Overview of asyncio 12575
A Conceptual Overview of asyncio この HOWTO では、 asyncio の基本的な仕組みをしっかり理解できるように説明します。 推奨される書き方がどのように動き、なぜ推奨されるのかを理解する助けになるでしょう。 asyncio の主要な概念について、疑問を持ってい ... 定したタイミングで完了にできます。 そのため、待機や再開の条件を独自に定めるための柔軟なインターフェースになります。 asyncio.sleep を自作する Future を使い、 asyncio.sleep() をまねた独自の非同期スリープ async_sleep を作る例を見ていきましょう。 次のコード ... はイベントループにいくつかのタスクを登録してから、 async_sleep(3) コルーチンを包む、 asyncio.create_task で作ったタスクを await します。 ほかのタスクの実行を妨げずに、3 秒経過してからこ ... work ()), asyncio . create_task ( other_work ()), asyncio . create_task ( other_work ()) ] print ( "Beginning asynchronous sleep at time: " f " { datetime . datetime . now () . strftime ( "%H:%M:%S" ) } ." ) await asyncio . create_task ( async_sleep ( ...
https://man.mtool.work/python/3.14/howto/a-conceptual-overview-of-asyncio.html
コマンドラインのイントロスペクションツール 11530
コマンドラインのイントロスペクションツール ソースコード: Lib/asyncio/tools.py asyncio モジュールは python -m asyncio でスクリプトとして実行でき、実行中の別の Python プロセスを変更したり再起動したりせずに、そのタスクグラフを調べられます。 こ ... ロセス ID を表示する次のプログラムを使います。 example.py import asyncio import os async def play ( track ): await asyncio . sleep ( 3600 ) print ( f "? Finished: { track } " ) async def album ( name , tracks ): async with asyncio . TaskGroup () as tg : ... /taskgroups.py:75 │ └── TaskGroup._aexit Lib/asyncio/taskgroups.py:124 │ ├── (T) TNDNBTG │ │ └── play example.py:4 │ │ └── sleep Lib/asyncio/tasks.py:702 │ └── (T) Levitate │ └── play example.py:4 │ └── sleep Lib/asyncio/tasks.py:702 └── (T) TMBTE └── ... /asyncio/taskgroups.py:75 └── TaskGroup._aexit Lib/asyncio/taskgroups.py:124 ├── (T) DYWTYLM │ └── play example.py:4 │ └── sleep Lib/asyncio/tasks.py:702 └── (T) Aqua Regia └── play example.py:4 └── sleep Lib/asyncio/tasks.py:702 await の関係を表すグラ ...
https://man.mtool.work/python/3.14/library/asyncio-tools.html
コルーチンとタスク 10921
コルーチンとタスク この節では、コルーチンと Task を利用する高レベルの asyncio の API の概略を解説します。 コルーチン ソースコード: Lib/asyncio/coroutines.py async/await 構文で宣言された コルーチン は、 asyncio を使ったアプリケーションを書く ... こから 1 秒待って "world" を出力します: >>> import asyncio >>> async def main (): ... print ( 'hello' ) ... await asyncio . sleep ( 1 ) ... print ( 'world' ) >>> asyncio . run ( main ()) hello world 単にコルーチンを呼び出しただけでは、コルーチンの実行ス ... 2 秒間待機してから "world" と出力します: import asyncio import time async def say_after ( delay , what ): await asyncio . sleep ( delay ) print ( what ) async def main (): print ( f "started at { time . strftime ( ' %X ' ) } " ) await say_after ( 1 , ... nate_task_group (): """Used to force termination of a task group.""" raise TerminateTaskGroup () async def job ( task_id , sleep_time ): print ( f 'Task { task_id } : start' ) await asyncio . sleep ( sleep_time ) print ( f 'Task { task_id } : done' ) ...
https://man.mtool.work/python/3.14/library/asyncio-task.html
asyncio --- 非同期 I/O 9704
asyncio --- 非同期 I/O Hello World! import asyncio async def main (): print ( 'Hello ...' ) await asyncio . sleep ( 1 ) print ( '... World!' ) asyncio . run ( main ()) asyncio は async/await 構文を使い 並行処理の コードを書くためのライブラリ ... ncio.run()". Type "help", "copyright", "credits" or "license" for more information. >>> import asyncio >>> await asyncio . sleep ( 10 , result = 'hello' ) 'hello' この REPL と PYTHON_BASIC_REPL の互換性は限定的です。 すべての機能と最新の機能を使うには ... 注釈 asyncio のソースコードは Lib/asyncio/ にあります。 他のマニュアルの関連ページ FastAPI 並行処理と async / await Linux JM sleep(1) PHP sleep() Linux JM sleep(3) Django async FastAPI Testing WebSockets ...
https://man.mtool.work/python/3.14/library/asyncio.html
sched --- イベントスケジューラー 9096
sched --- イベントスケジューラー ソースコード: Lib/sched.py sched モジュールは、汎用的なイベントスケジューラーを実装するクラスを定義しています: class sched. scheduler ( timefunc = time.monotonic , delayfunc = time.sleep ) scheduler クラスは ... 用出来るようになりました。 以下はプログラム例です: >>> import sched , time >>> s = sched . scheduler ( time . time , time . sleep ) >>> def print_time ( a = 'default' ): ... print ( "From print_time" , time . time (), a ) ... >>> def print_some_times ( ... t, kwargs を持った named tuple の形式になります。 他のマニュアルの関連ページ Linux JM cancel(1) Linux JM sched(7) Linux JM sleep(3) Linux JM sleep(1) PHP sleep() PHP ev.stop ...
https://man.mtool.work/python/3.14/library/sched.html
ライブラリと拡張 FAQ 8659
ライブラリと拡張 FAQ ライブラリ一般の質問 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか? ライブラリリファンレス から関係がありそうな標準ライブラリモジュールがあるかどうか調べてください。 (標準ライブラリに何があるかが ... , i ) for i in range ( 10 ): T = threading . Thread ( target = thread_task , args = ( str ( i ), i )) T . start () time . sleep ( 10 ) # <---------------------------! しかし、実際は (ほとんどのプラットフォームでは) スレッドは並行して実行されるのではな ... 始しないからです。 簡単に直すには、関数の実行の最初にちょっとスリープを加えることです: def thread_task ( name , n ): time . sleep ( 0.001 ) # <--------------------! for i in range ( n ): print ( name , i ) for i in range ( 10 ): T = threading . Thread ... ( target = thread_task , args = ( str ( i ), i )) T . start () time . sleep ( 10 ) time.sleep() の良い遅延時間を推測しようとするよりも、セマフォのような仕組みを使う方が良いでしょう。 1 つのアイディア ...
https://man.mtool.work/python/3.14/faq/library.html
asyncio とフリースレッド Python 8659
asyncio とフリースレッド Python asyncio uses an event loop as a scheduler to enable highly efficient concurrency by switching between tasks to allow non-blocking I/O operations. This results in better performance for I/O-bound use cases. It ... asyncio import threading async def worker ( name : str ) -> None : print ( f "Worker { name } starting" ) await asyncio . sleep ( 1 ) print ( f "Worker { name } done" ) def run_loop ( name : str ) -> None : asyncio . run ( worker ( name )) threads = ... ( q : queue . Queue [ int ]) -> None : while True : try : item = q . get_nowait () except queue . Empty : await asyncio . sleep ( 0.1 ) continue except queue . ShutDown : break print ( f "Consumed { item } " ) await asyncio . sleep ( item ) q : queue ... de an event loop on its own thread, yet they communicate safely through queue.Queue . When the queue is empty the consumer sleeps briefly and tries again. When the producer is done it calls shutdown() , which causes subsequent get_nowait() calls to ra ...
https://man.mtool.work/python/3.14/library/asyncio-threading.html
time --- 時刻データへのアクセスと変換 8393
time --- 時刻データへのアクセスと変換 このモジュールでは、時刻に関するさまざまな関数を提供します。関連した機能について、 datetime , calendar モジュールも参照してください。 このモジュールは常に利用可能ですが、すべての関数がすべてのプラットフ ... ば、ほとんどの Unix システムにおいて、クロックの 1 ティックの精度は 50 から 100 分の 1 秒に過ぎません。 一方、 time() および sleep() は Unix の同等の関数よりましな精度を持っています。時刻は浮動小数点数で表され、 time() は可能なかぎり最も正確な時刻を (Un ... ix の gettimeofday() があればそれを使って) 返します。また sleep() にはゼロでない端数を与えることができます (Unix の select() があれば、それを使って実装しています)。 gmtime() , localtime( ... 3. time. process_time_ns ( ) → int process_time() に似ていますが、ナノ秒単位の時刻を返します。 Added in version 3.7. time. sleep ( seconds , / ) Suspend execution of the calling thread for the given number of seconds. The argument may be a floating-po ...
https://man.mtool.work/python/3.14/library/time.html
asyncio での開発 8300
asyncio での開発 非同期プログラミングは、従来の「逐次的」なプログラミングとは異なります。 このページはよくある間違いや落とし穴を列挙し、それらを回避する方法を説明します。 デバッグモード asyncio はデフォルトで本運用モードで実行されます。いっ ... は結果にアクセスするための concurrent.futures.Future オブジェクトを返します: async def coro_func (): return await asyncio . sleep ( 1 , 42 ) # 後で、別の OS スレッド内で実行する: future = asyncio . run_coroutine_threadsafe ( coro_func (), loop ) # 結果 ... r (): try : yield 1 finally : assert work_done async def rows (): global work_done try : yield 2 finally : await asyncio . sleep ( 0.1 ) # 非同期の処理を模倣する work_done = True async def main (): async for c in cursor (): async for r in rows (): bre ... sary. 次に示す例について考えてみてください。: import asyncio async def agenfn (): try : yield 10 finally : await asyncio . sleep ( 0 ) with asyncio . Runner () as runner : agen = agenfn () print ( runner . run ( anext ( agen ))) del agen 出力: 10 Exce ...
https://man.mtool.work/python/3.14/library/asyncio-dev.html
PREV 1 2 3 4 NEXT