Skip to content

Commit

Permalink
test: Use threads instead of MP in reverse tunnel test (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
oakreid committed Dec 1, 2021
1 parent e9ba3b4 commit fd4f6c5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tests/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import sys
import time
from copy import deepcopy
from multiprocessing import Process, Queue
from multiprocessing import Queue
from threading import Thread

import env
import pytest
Expand Down Expand Up @@ -490,10 +491,6 @@ def test_tunnel(self):
print(p.communicate())
assert data == b"hello world"

@pytest.mark.skip(
sys.version_info >= (3, 8) and sys.platform.startswith("darwin"),
reason="Hangs when using spawn instead of fork (macOS 3.8+ default)",
)
def test_reverse_tunnel(self):

with self._connect() as rem:
Expand All @@ -508,11 +505,11 @@ def test_reverse_tunnel(self):
p = (rem.python["-u"] << get_unbound_socket_remote).popen()
remote_socket = p.stdout.readline().decode("ascii").strip()
queue = Queue()
tunnel_server = Process(target=serve_reverse_tunnel, args=(queue,))
tunnel_server = Thread(target=serve_reverse_tunnel, args=(queue,))
tunnel_server.start()
message = str(time.time())
with rem.tunnel(12223, remote_socket, dhost="localhost", reverse=True):
remote_send_af_inet = """import sys, socket
remote_send_af_inet = """import socket
s = socket.socket()
s.connect(("localhost", {}))
s.send("{}".encode("ascii"))
Expand All @@ -521,7 +518,7 @@ def test_reverse_tunnel(self):
remote_socket, message
)
(rem.python["-u"] << remote_send_af_inet).popen()
tunnel_server.join()
tunnel_server.join(timeout=1)
assert queue.get() == message

def test_get(self):
Expand Down

0 comments on commit fd4f6c5

Please sign in to comment.