Git Product home page Git Product logo

Comments (3)

ioquatix avatar ioquatix commented on May 21, 2024

I've added a spec for this, demonstrating the issue. It's not a bug, but it's a semantic design decision.

subject.async do |task|
	socket = Async::TCPSocket.connect("localhost", port)
	
	# I'm not sure if this is the right behaviour or not. Without a significant amont of work, async sockets are tied to the task that creates them.
	expect do
		subject.async(socket) do |client|
			client.write(data)
			expect(client.read(512)).to be == data
		end
	end.to raise_error(ArgumentError, /already registered with selector/)
end

One option would be to add an unbind method which removes the socket from the current task and allows it to be used elsewhere for async function calls.

Also, if an exception happens in a situation like this - who is responsible for tidying up the dangling socket?

from async.

ioquatix avatar ioquatix commented on May 21, 2024

The dangling socket problem is solved using Task#with and Reactor#with. An unbind method is still not implemented.

from async.

ioquatix avatar ioquatix commented on May 21, 2024

It's now possible to use wrapped io in any task within the same reactor. It should be possible to unwrap or dup the IO to a different reactor as needed too.

from async.

Related Issues (20)

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.