Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def _run_test(self) -> None:
recv_task = await curio.spawn(self._recv_packets)
await self._send_packets()
print('All packets sent')
try:
await curio.timeout_after(self._timeout, recv_task.join())
except curio.TaskTimeout:
await recv_task.cancel()
def _get_hub_class(self, hub_type, sensor, sensor_name, capabilities):
stop_evt = Event()
@attach(sensor, name=sensor_name, capabilities=capabilities)
class TestHub(hub_type):
async def sensor_change(self):
pass
async def run(self):
pass
await stop_evt.wait()
return TestHub, stop_evt
async def main():
p = subprocess.Popen([executable, '-c', 'import time;time.sleep(1)'])
code = await p.wait()
assert code == 0
Returns
-------
stdout, stderr
Decoded standard output and standard error text
'''
args = ['/usr/bin/env'] + list(args)
print()
print('* Executing', args)
epics_env = ca.get_environment_variables()
env = dict(PATH=os.environ['PATH'],
EPICS_CA_AUTO_ADDR_LIST=epics_env['EPICS_CA_AUTO_ADDR_LIST'],
EPICS_CA_ADDR_LIST=epics_env['EPICS_CA_ADDR_LIST'])
p = curio.subprocess.Popen(args, env=env,
stdout=curio.subprocess.PIPE,
stderr=curio.subprocess.PIPE)
await p.wait()
raw_stdout = await p.stdout.read()
raw_stderr = await p.stderr.read()
stdout = raw_stdout.decode('latin-1')
stderr = raw_stderr.decode('latin-1')
return stdout, stderr
def run(self) -> None:
try:
curio.run(self._run_test)
except KeyboardInterrupt:
print('Cancelled')
def my_test_ipv6():
server, bind_addr, _ = get_server("http://user:password@[::1]:0")
bind_address = f"{bind_addr[0]}:{bind_addr[1]}"
client = get_client(f"http://user:password@{bind_address}")
curio.run(main(make_request(client), server))
async def main(ch1, ch2):
async with ch1, ch2:
t1 = await spawn(server, ch1)
t2 = await spawn(client, ch2)
await t1.join()
await t2.join()
async def _on_data(self, data: bytes, addr: Tuple[str, int]) -> None:
task = await curio.spawn(self._sock.sendto, b'response', addr)
await self._tasks.put(task)
async def task():
server_task = await curio.spawn(curio_server)
try:
await client()
finally:
await server_task.cancel()
break
pvname = res.result
await connect_task.spawn(ctx.create_channel, pvname)
while True:
res = await connect_task.next_done()
if res is None:
break
curio_channel = res.result
pvname = curio_channel.channel.name
pvs[pvname] = curio_channel
assert len(pvs) == len(pv_names)
# TODO: can't successfully test as this hammers file creation; this
# will be important to resolve...
await curio.sleep(1)