Git Product home page Git Product logo

grokking_concurrency's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grokking_concurrency's Issues

User threads starvation

# simulating some real action here
time.sleep(random.randrange(1, 3))
lock.release_write()

In Librarian::run function, Librarian thread releases a writer lock and then immediately acquires a writer lock.
Other User threads can not acquire a writer lock in RWLock::acquire_read function. so... User threads result in starvation.
I think Librarian thread should release a writer lock before sleeping. :)

Why does repeatedly registering `server_socket` to the event loop enable multiple connections to clients?

I noted a big fix 667d37e added the following snippet to method _on_accept of class Server:

self.event_loop.register_event(self.server_socket, select.POLLIN,
self._on_accept)

Basically, the snippet re-register server_socket in the event loop every time a new connection is established with a client. As 667d37e said, the server cannot connect multiple clients without re-registration. In contrast, _on_read and _on_write handlers do not re-register sockets, but a client may send messages to the server multiple times.

What makes server_socket different so that we must re-register it to enble multiple connections to clients?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.