Skip to content

Instantly share code, notes, and snippets.

View ddcatgg's full-sized avatar

DDGG ddcatgg

  • Shanghai
View GitHub Profile
@ddcatgg
ddcatgg / asyncio_loop_in_thread.py
Created November 23, 2022 16:04 — forked from dmfigol/asyncio_loop_in_thread.py
Python asyncio event loop in a separate thread
"""
This gist shows how to run asyncio loop in a separate thread.
It could be useful if you want to mix sync and async code together.
Python 3.7+
"""
import asyncio
from datetime import datetime
from threading import Thread
from typing import Tuple, List, Iterable
@ddcatgg
ddcatgg / aioudp.py
Created November 23, 2022 15:57 — forked from vxgmichel/aioudp.py
High-level UDP endpoints for asyncio
"""Provide high-level UDP endpoints for asyncio.
Example:
async def main():
# Create a local UDP enpoint
local = await open_local_endpoint('localhost', 8888)
# Create a remote UDP enpoint, pointing to the first one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import cookielib
import json
import tempfile
import mechanize
import re
import requests