question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

create a sans-io docker client class and impliment Client with blocking requests

See original GitHub issue

use https://github.com/mikeal/deferred to create a sans-io version of Client (SansIOClient) that requires something like:

class SimpleStream(object):
    def next(self) -> Deferred:
        ...

class IOAdapter(object):
    def request(self, **kwargs) -> Deferred:
        ...

    def stream(self, **kwargs) -> SimpleStream:
        ...

    def unwrap_deferred(self, deferred: Deferred) -> Any:
        ...

and then implement it with something like:

class BlockingSimpleStream(SimpleStream):
    def __init__(self, stream):
        self.generator = _stream_helper(stream):
    def next(self) -> Deferred:
        return deferred.succeeded(next(self.generator))

class BlockingIOAdapter(IOAdapter):
    def __init__(session: requests.Session):
        self.session = session

    def request(self, **kwargs) -> Deferred:
        return deferred.execute(self.session.request, **kwargs)

    def stream(self, **kwargs) -> BlockingSimpleStream:
        return BlockingSimpleStream(self.session.request(**kwargs, stream=True))

    def unwrap_deferred(self, d: Deferred):
        return deferred.waitForDeferred(d).getResult()

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cectoncommented, May 5, 2017

I made a small attempt here to get docker-py asynchronous: https://github.com/tenforce/docker-py-aiohttp This is actually a wrapper around docker-py. I suppose it’s not really what you want, especially since it is strongly bound to aiohttp and I think you want something more generic right?

0reactions
graingertcommented, Oct 6, 2016

@shin- is this something you guys would be interesting? It would take me a little bit of work up-front, so I’d like to know if this feature is something you would be interested in having.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Examples using the Docker Engine SDKs and Docker API
This first example shows how to run a container using the Docker API. On the command line, you would use the docker run...
Read more >
Client API - docker-py Documentation - Read the Docs
To instantiate a Client class that will allow you to communicate with a ... Return a blocking generator you can iterate over to...
Read more >
Docker Java - GitHub
Java Docker API Client. Contribute to docker-java/docker-java development by creating an account on GitHub.
Read more >
FOR608: Enterprise-Class Incident Response & Threat Hunting
Learn analysis techniques for responding to Linux and Mac operating systems; Analyze containerized microservices such as Docker containers; Correlate and ...
Read more >
Backend only works in localhost React + Springboot + docker
The React Frontend normally runs in the clients browser (If you don't ... class MyCrossOriginController { // this should now allow requests ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found