-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
When doing a lot of ca_connects in a short space of time (1000ish in a few seconds) some of them take a longer than usual time to connect. I've had a go at reproducing this, and I have a fairly minimal reproducer:
import ctypes
import subprocess
import sys
import tempfile
import time
from queue import Queue
import pytest
from epicscorelibs.ca import cadef
NUM = 1000
@pytest.fixture(scope="module")
def ioc():
cadef.ca_context_create(1)
with tempfile.NamedTemporaryFile() as records:
records.write(
b"\n".join(b'record(longout, "LONGOUT%d") {\n}' % i for i in range(NUM))
)
records.flush()
process = subprocess.Popen(
[sys.executable, "-m", "epicscorelibs.ioc", "-d", records.name],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
yield process
try:
process.communicate("exit()")
except ValueError:
# Someone else already called communicate
pass
@pytest.mark.parametrize("iteration", [i for i in range(NUM)])
def test_get_pv(iteration, ioc):
q = Queue()
@cadef.connection_handler
def put_on_queue(args):
if args.op == cadef.CA_OP_CONN_UP:
q.put(None)
t = time.time()
chid = ctypes.c_void_p()
cadef.ca_create_channel(
"LONGOUT%d" % iteration, put_on_queue, 0, 0, ctypes.byref(chid)
)
q.get()
cadef.ca_clear_channel(chid.value)
assert time.time() - t < 2This will make an IOC with 1000 PVs, then do a ca_connect and wait for connection to each of those PVs serially. Most take about 0.1s to connect, but about 1 in 1000 will take between 2 and 9 seconds. Have you ever seen this @mdavidsaver ?
Metadata
Metadata
Assignees
Labels
No labels