slack-bridge: Use threading instead of multiprocessing.

This will fix the bug reported in
https://chat.zulip.org/#narrow/stream/127-integrations/topic/bridge_with_slack/near/1182555,
which is specific to macOS.

The error message is
```
AttributeError: Can't pickle local object 'SlackBridge.zulip_to_slack.<locals>._zulip_to_slack'
```
This commit is contained in:
rht 2021-05-20 09:21:14 -04:00 committed by Tim Abbott
parent 2d9cf64db8
commit 5b2da94ba5

View file

@ -5,7 +5,7 @@ import sys
import os
import argparse
import traceback
import multiprocessing as mp
import threading
import zulip
import slack_sdk
from slack_sdk.rtm import RTMClient
@ -123,8 +123,8 @@ if __name__ == "__main__":
try:
sb = SlackBridge(config)
zp = mp.Process(target=sb.zulip_client.call_on_each_message, args=(sb.zulip_to_slack(),))
sp = mp.Process(target=sb.run_slack_listener, args=())
zp = threading.Thread(target=sb.zulip_client.call_on_each_message, args=(sb.zulip_to_slack(),))
sp = threading.Thread(target=sb.run_slack_listener, args=())
print("Starting message handler on Zulip client")
zp.start()
print("Starting message handler on Slack client")