event-driven

Python - How can I make this code asynchronous?

删除回忆录丶 提交于 2019-12-03 12:21:14
Here's some code that illustrates my problem: def blocking1(): while True: yield 'first blocking function example' def blocking2(): while True: yield 'second blocking function example' for i in blocking1(): print 'this will be shown' for i in blocking2(): print 'this will not be shown' I have two functions which contain while True loops. These will yield data which I will then log somewhere (most likely, to an sqlite database). I've been playing around with threading and have gotten it working. However, I don't really like it... What I would like to do is make my blocking functions

Event-driven architecture and structure of events

烂漫一生 提交于 2019-12-03 12:13:44
I'm new to EDA and I've read a lot about benefits and would probably be interested to apply it during my next project but still haven't understood something. When raising an event, which pattern is the most suited: Name the event "CustomerUpdate" and include all information (updated or not) about the customer Name the event "CustomerUpdate" and include only information that have really been updated Name the event "CustomerUpdate" and include minimum information (Identifier) and/or a URI to let the consumer retrieves information about this Customer. I ask the question because some of our events

why Redis is single threaded(event driven)

南笙酒味 提交于 2019-12-03 09:56:02
I am trying to understanding basics of Redis. One that that keep coming everywhere is, Redis is single threaded that makes things atomic.But I am unable to imagine how this is working internally.I have below doubt. Don't we design a server Single thread if it is IO bound application(like Node.js),where thread got free for another request after initiating IO operation and return data to client once IO operation is finished(providing concurrency). But in case of redis all data are available in Main Memory,We are not going to do IO operation at all.So then why Redis is single threaded?What will

What is the relation of 'Event Driven' and 'Object Oriented' programming?

懵懂的女人 提交于 2019-12-03 09:22:49
问题 These days, I hear almost everywhere about 'event driven' programming. Wikipedia says: In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or messages from other programs/threads. Event-driven programming is the dominant paradigm used in graphical user interfaces and other applications (e.g. Javascript web applications) that are centered around

PHP: Am I mixing up event-driven programming with signals-aware interfaces (Signal and Slots / Observer Pattern)?

▼魔方 西西 提交于 2019-12-03 03:12:13
问题 I've seen a lot of people saying that Symfony2, Zend Framework 2 and others are event-driven. On the desktop world, by event-driven programming I understand that the application will notify its observers whenever its state changes. Since PHP applications are state-less there's no way to do such thing. I.E. Having observers tied to the view observing changes while the user uses the interface. Instead it needs a new request process in order to update the view. So, it's not an event but a whole

Non-blocking (async) DNS resolving in Java

一笑奈何 提交于 2019-12-03 01:11:50
Is there a clean way to resolve a DNS query (get IP by hostname) in Java asynchronously, in non-blocking way (i.e. state machine, not 1 query = 1 thread - I'd like to run tens of thousands queries simultaneously, but not run tens of thousands of threads)? What I've found so far: Standard InetAddress.getByName() implementation is blocking and looks like standard Java libraries lack any non-blocking implementations. Resolving DNS in bulk question discusses similar problem, but the only solution found is multi-threaded approach (i.e. one thread working on only 1 query in every given moment of a

EventMachine vs Node.js

微笑、不失礼 提交于 2019-12-03 01:06:22
问题 I'm going to develop a collaborative site, and one of the features will be collaborative editing with realtime changes. i.e. when two or more users are editing the same doc, they can see each other changes as soon as they happen. I have some experience with Ruby on Rails, so I was thinking about using EventMachine, but with all this hype around Node.js, I am know considering using it instead. So, what would be the main benefits of using Node.js instead of EventMachine? tl;dr What are the main

What is the relation of 'Event Driven' and 'Object Oriented' programming?

可紊 提交于 2019-12-02 23:51:55
These days, I hear almost everywhere about 'event driven' programming. Wikipedia says: In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or messages from other programs/threads. Event-driven programming is the dominant paradigm used in graphical user interfaces and other applications (e.g. Javascript web applications) that are centered around performing certain actions in response to user input. Isn't this exactly our old friend OOP? And if this

EventMachine vs Node.js

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 16:23:16
I'm going to develop a collaborative site, and one of the features will be collaborative editing with realtime changes. i.e. when two or more users are editing the same doc, they can see each other changes as soon as they happen. I have some experience with Ruby on Rails, so I was thinking about using EventMachine, but with all this hype around Node.js, I am know considering using it instead. So, what would be the main benefits of using Node.js instead of EventMachine? tl;dr What are the main differences between EventMachine and Node.js (besides the language)? EventMachine has nothing to do

Pattern to manage views in backbone

血红的双手。 提交于 2019-12-02 14:56:08
Coming from GWT, Backbone seems to miss a built-in solution on how to handle the life-cycle of a view. In GWT, every activity, which is more or less the equivalent to a View in Backbone, is managed by an ActivityManager which calls onStart/onStop on the activity, passing the eventBus and the element where the Activity can be rendered in. On stop, the ActivityManager will unbind all events the activity has bind to the eventbus and remove the view from the DOM. In Backbone, it's easy to bind the events to model and collection but you have to remove them manually and there is no common api method