Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses a CapacityLimiter on trio instead of a Semaphore #19

Closed
miracle2k opened this issue Sep 9, 2018 · 1 comment
Closed

Uses a CapacityLimiter on trio instead of a Semaphore #19

miracle2k opened this issue Sep 9, 2018 · 1 comment

Comments

@miracle2k
Copy link
Contributor

Those two are not identical:

import trio

async def main():
	c = trio.Semaphore(10)
	async with c:
		print('one in')
		async with c:
			print('two in')

trio.run(main)
one in
two in

but:

import trio


async def main():
	c = trio.CapacityLimiter(10)
	async with c:
		print('one in')
		async with c:
			print('two in')


trio.run(main)
one in
RuntimeError: this borrower is already holding one of this CapacityLimiter's tokens

This means that I cannot open two connections in the same task https://github.com/Fuyukai/riopg.

@theelous3
Copy link
Owner

theelous3 commented Sep 10, 2018

Ooo! Nice lib. Didn't realise F was making this. Neato.

Switched and updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants