Skip to content

Instantly share code, notes, and snippets.

View apatrushev's full-sized avatar

Anton Patrushev apatrushev

View GitHub Profile
### Keybase proof
I hereby claim:
* I am apatrushev on github.
* I am apatrushev (https://keybase.io/apatrushev) on keybase.
* I have a public key ASDk0Vu7jZ9Oxm2Bs0DIUO9-Dr3iLsMSxwCSPzM02YOsSAo
To claim this, I am signing this object:
extern crate actix;
extern crate tokio;
extern crate tokio_codec;
extern crate futures;
extern crate bytes;
use bytes::BytesMut;
use std::io;
use std::net::SocketAddr;
use futures::{Stream, Sink, Future};
extern crate actix;
extern crate tokio_core;
extern crate futures;
use std::time::Duration;
use futures::Stream;
use tokio_core::reactor::Interval;
use actix::prelude::*;
use actix::{Actor, Context, StreamHandler, SpawnHandle, Arbiter};
@apatrushev
apatrushev / background_loop.py
Last active July 27, 2018 20:07
background asyncio loop. the idea behind was to integrate asyncio code with sync code and/or other loops. this approach will work if you need not tight integration but will be happy with callbacks between (sync/your loop) and asyncio.
import time
import threading
import asyncio
import janus
class BackgroundLoopBase(threading.Thread):
def __init__(self, *args, **kwargs):
if len(args) > 1 or 'target' in kwargs:
raise RuntimeError('target override not supported')