전체 글 (256) 썸네일형 리스트형 Python: 동기, 비동기 함수 여부에 상관없이 실행하기 # inspect.iscoroutinefunction 함수를 인자로 받아서, 해당 함수가 동기, 비동기 중 어떤 방식으로 선언되어 있는지는 먼저 판단하고,거기에 맞게 함수를 실행하면 된다. 파이썬 내장 라이브러리인 inspect 내의 iscoroutinefunction 함수를 이용 함수명 대로, coroutine 여부를 판단해준다 async가 붙은 함수: is coroutine function? yes -> inspect.iscoroutinefunction(func): True async 붙지 않은 함수: is coroutine function? no -> inspect.iscoroutinefunction(func): False 예제 코드import inspectimport asynciodef is_async_function(func): re.. FastAPI + SQLAlchemy: DB Connection이 지속적으로 생기는 문제 FastAPI는 일반적으로 SQLAlchemy와 함께 사용하며,다수의 커넥션풀을 유지하기 위해서 QueuePool을 사용한다.(비동기 데이터베이스 라이브러리 사용시에는 QueuePool이 아닌 async에 맞는 풀 사용)# database.pyfrom sqlalchemy import create_enginefrom sqlalchemy.pool import QueuePoolfrom sqlalchemy.orm import sessionmakersync_engine = create_engine( SYNC_DATABASE_URL, poolclass=QueuePool, pool_size=20, max_overflow=5, pool_timeout=30, pool_recycle=360.. aiohttp: async requests code example install: pip install aiohttp 다수의 request를 비동기적으로 요청하기 (예제에서는 1000번) - put 요청 기준 - post도 동일한 방식 (메소드만 put -> post 변경) import aiohttpimport asyncioasync def send_put_request(session, url, data, headers): async with session.put(url, json=data, headers=headers) as response: return response.status, await response.text()async def main(url, data, headers): async with aiohttp.ClientSession.. MySQL: max_connections 수정 Check current max_connections:SHOW VARIABLES LIKE 'max_connections'; Changing the maximum number of connections that MySQL can handle involves modifying the max_connections setting. This parameter determines how many concurrent connections MySQL can accept. Here’s how you can adjust this setting, either temporarily or permanently:Temporarily Changing Max Connections1. Via MySQL Command Line:Conn.. FastAPI + SQLAlchemy: connection pool log 찍기 # Pool 커스텀 https://github.com/Junanjunan/g6/commit/709b910470c6c216f5e7d5870f1403095b7ef44e 로그 생성용 커스텀 커넥션 풀 설정 · Junanjunan/g6@709b910Junanjunan committed May 3, 2024github.com C: #ifndef / likely(x) / unlikely(x) / __builtin_expect(!!(x), 1) #if (CONFIG_COMPILER_OPTIMIZATION_PERF)#ifndef likely#define likely(x) __builtin_expect(!!(x), 1)#endif#ifndef unlikely#define unlikely(x) __builtin_expect(!!(x), 0)#endif#else#ifndef likely#define likely(x) (x)#endif#ifndef unlikely#define unlikely(x) (x)#endif#endif/** * Macro which can be used to check the condition. If the condition is not 'true', it prints the message * and .. ESP-IDF: idf.py --ccache build ccache가 설치되어 있는 경우 build 속도가 상당히 빨라진다고 해서 테스트를 해보았다.블루투스 example들을 build 하는 경우 정말 빌드할 것이 많아서 자잘한 수정을 하고 빌드를 하는 경우 꽤 성가시다. 공식 홈페이지에는 윈도우나 리눅스나 알집 형태로 받도록 되어 있다.https://c.. Bluetooth - HID: Little Endian, Big Endian 참고 블로그:https://zion830.tistory.com/38https://softtone-someday.tistory.com/20<a href="https://techz.. 이전 1 ··· 7 8 9 10 11 12 13 ··· 32 다음