| 1 | From 1697feef17dff0d5fc873c5271c74bbde5d8af60 Mon Sep 17 00:00:00 2001
|
| 2 | From: =?UTF-8?q?Sergio=20Pastor=20P=C3=A9rez?=
|
| 3 | <[email protected]>
|
| 4 | Date: Sun, 24 May 2026 18:03:26 +0200
|
| 5 | Subject: [PATCH 1/2] integrations: Fix IRC mirror timing out when relaying IRC
|
| 6 | messages.
|
| 7 |
|
| 8 | * zulip/integrations/bridge_with_irc/irc_mirror_backend.py (fresh_session): New
|
| 9 | procedure. Ensure forked processes have a clean client to ensure they don't
|
| 10 | share the SSL sockets of the parent.
|
| 11 |
|
| 12 | This patch won't be needed once the following issue is merged upstream:
|
| 13 | https://github.com/zulip/python-zulip-api/pull/917
|
| 14 | ---
|
| 15 | .../bridge_with_irc/irc_mirror_backend.py | 12 +++++++++++-
|
| 16 | 1 file changed, 11 insertions(+), 1 deletion(-)
|
| 17 |
|
| 18 | diff --git a/zulip/integrations/bridge_with_irc/irc_mirror_backend.py b/zulip/integrations/bridge_with_irc/irc_mirror_backend.py
|
| 19 | index 8fdd6c98..e9ba1009 100644
|
| 20 | |
| 21 | |
| 22 | @@ -5,6 +5,7 @@ from typing import Any, Dict, Optional
|
| 23 |
|
| 24 | import irc.bot
|
| 25 | import irc.strings
|
| 26 | +import requests
|
| 27 | from irc.client import Event, ServerConnection, ip_numstr_to_quad
|
| 28 |
|
| 29 |
|
| 30 | @@ -89,7 +90,16 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
| 31 | for line in msg["content"].split("\n"):
|
| 32 | send(line)
|
| 33 |
|
| 34 | - z2i = mp.Process(target=self.zulip_client.call_on_each_message, args=(forward_to_irc,))
|
| 35 | + def fresh_session() -> None:
|
| 36 | + # Create a new client so the child doesn't share the parent's SSL
|
| 37 | + # sockets after forking in 'mp.Process'.
|
| 38 | + self.zulip_client.session.close()
|
| 39 | + new_session = requests.Session()
|
| 40 | + new_session.auth = (self.zulip_client.email, self.zulip_client.api_key)
|
| 41 | + self.zulip_client.session = new_session
|
| 42 | + self.zulip_client.call_on_each_message(forward_to_irc)
|
| 43 | +
|
| 44 | + z2i = mp.Process(target=fresh_session)
|
| 45 | z2i.start()
|
| 46 |
|
| 47 | def on_privmsg(self, c: ServerConnection, e: Event) -> None:
|
| 48 | --
|
| 49 | 2.54.0
|
| 50 |
|