跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[程序员] 想问下大家平时用 Python 中 asyncio 库的时候,有什么技巧?或者说用了哪些 high level 或 low level 的 api?

发表于

比如下面我经常用的

  1. asyncio.run(coro) 运行顶层的协程,直到完成,适合简单的脚本和测试。
  2. asyncio.create_task(coro) 创建一个异步任务,用于并行执行协程。
  3. asyncio.gather(*coros, return_exceptions=False) 并行运行多个协程,收集它们的结果。
  4. asyncio.Lock 异步锁,用于同步访问共享资源。
  5. asyncio.Event 异步事件,用于在协程间通信。
  6. asyncio.Semaphore 和 asyncio.BoundedSemaphore 条件变量,允许协程等待某个条件成立。

看看大家平时还用了什么 API ?获取能学到新东西

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.