Browse Source

[Python/Blacksheep] Adjust the number of single-process database connections in the `pypy` (#9936)

* Adjust the number of single-process database connections in the `pypy` environment.

* fix error
nazo 2 months ago
parent
commit
9e334c56f5
1 changed files with 2 additions and 1 deletions
  1. 2 1
      frameworks/Python/blacksheep/app-socketify.py

+ 2 - 1
frameworks/Python/blacksheep/app-socketify.py

@@ -13,8 +13,9 @@ READ_ROW_SQL = 'SELECT "id", "randomnumber" FROM "world" WHERE id = %s'
 WRITE_ROW_SQL = 'UPDATE "world" SET "randomnumber"=%s WHERE id=%s'
 ADDITIONAL_ROW = [0, "Additional fortune added at request time."]
 CORE_COUNT = multiprocessing.cpu_count()
+MAX_DB_CONNECTIONS = 2000
 
-MAX_POOL_SIZE = CORE_COUNT * 2
+MAX_POOL_SIZE = min(CORE_COUNT * 2, MAX_DB_CONNECTIONS // CORE_COUNT, 32)
 MIN_POOL_SIZE = max(1, MAX_POOL_SIZE // 2)
 db_pool = None