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

Turn DWaveSampler into context manager #91

Open
randomir opened this issue Jul 19, 2018 · 2 comments
Open

Turn DWaveSampler into context manager #91

randomir opened this issue Jul 19, 2018 · 2 comments

Comments

@randomir
Copy link
Member

Blocked by #77.

@arcondello
Copy link
Member

One thing we could do is only keep the thread pool open if inside a context. So

sampler = DWaveSampler()
sampler.sample_ising(...)
sampler.sample_ising(...)

would be equivalent (from a cloud-client perspective) to

with DWaveSampler() as sampler:
    sampler.sample_ising(...)
with DWaveSampler() as sampler:
    sampler.sample_ising(...)

where as

with DWaveSampler() as sampler:
    sampler.sample_ising(...)
    sampler.sample_ising(...)

would only open one thread pool.

However this would impact performance pretty significantly in the case of multiple calls outside of a context manager. Probably better to do the singleton threadpool mentioned by @randomir in #171 (comment).

@randomir
Copy link
Member Author

randomir commented Oct 1, 2019

@arcondello, I think we'll soon have singleton threadpools, as they are related to dwavesystems/dwave-cloud-client#326.

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