Skip to content

Commit 3ff3a81

Browse files
authored
Merge pull request #47 from sususweet/fix/psycopg-connection-issue
fix: psycopg3 connection issues on windows debugging environment.
2 parents 58a0d3b + 03b6980 commit 3ff3a81

4 files changed

Lines changed: 7 additions & 3 deletions

File tree

main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
plugin = Plugin(DifyPluginEnv(MAX_REQUEST_TIMEOUT=MAX_REQUEST_TIMEOUT))
3838

39+
if sys.platform == 'win32':
40+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
3941

4042
def _graceful_shutdown() -> None:
4143
logger.info("Initiating graceful shutdown of Mem0 plugin")

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ dependencies = [
99
"azure-identity",
1010
"langchain-neo4j",
1111
"rank-bm25",
12-
"psycopg[binary,pool]",
12+
"psycopg[binary,pool] ; sys_platform != 'win32'",
1313
"dify_plugin",
14+
"psycopg2-binary ; sys_platform == 'win32'",
1415
"tiktoken",
1516
"cohere>=6.1.0",
1617
"ollama==0.6.1"

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ openai
33
azure-identity
44
langchain-neo4j
55
rank-bm25
6-
psycopg[binary,pool] # psycopg3 with connection pool support
6+
psycopg[binary,pool] ; sys_platform != "win32" # psycopg3 with connection pool support (non-Windows)
7+
psycopg2-binary ; sys_platform == "win32" # psycopg2 pool (Windows only)
78
dify_plugin
89
tiktoken # Accurate token counting for conversation processing
910
cohere>=6.1.0

utils/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
# Write operations: default timeout for all write operations (add/update/delete/delete_all)
5454
# NOTE: In async_mode, write tools enqueue work and return immediately, but the background
5555
# operation still uses this timeout as a safeguard.
56-
WRITE_OPERATION_TIMEOUT: int = 15
56+
WRITE_OPERATION_TIMEOUT: int = 45
5757

5858
# Dify API pagination constraints
5959
# Maximum items (conversations or messages) that can be fetched in a single API request

0 commit comments

Comments
 (0)