Skip to content

Instantly share code, notes, and snippets.

View nirs's full-sized avatar

Nir Soffer nirs

  • IBM
  • 05:23 (UTC +03:00)
View GitHub Profile
>>> len('{"transfer_id": "78e1d6c7-6584-4ee7-83db-0f8033fd446f", "destination_url": "https://ovnuxa05.example.com:54322/images/5b8ae2c9-bd3c-46ea-914e-3768cbd27581", "is_ovirt_host": false}')
180
>>> len('{"transfer_id": "3ff1fc5f-3828-4e0a-afa1-6e828f17460f", "destination_url": "https://ovna01.example.com:54322/images/27f41b83-4b87-4480-951c-9a2f321090f3", "is_ovirt_host": false}e}')
180
@nirs
nirs / direct_copy.py
Created December 19, 2017 00:57
Copying data from disk to disk using direct io
import mmap
import io
from contextlib import closing
BUF_SIZE = 8 * 1024**2
buf = mmap.mmap(-1, BUF_SIZE)
with closing(buf), io.FileIO(src_path, "r") as src, io.FileIO(dst_path, "r+") as dst:
while True:
@nirs
nirs / health-before.log
Last active January 18, 2016 00:10
before reourceref leak fix
MainThread::INFO::2016-01-18 01:31:08,590::health::60::health::(start) Starting health monitor (interval=60)
Thread-13::DEBUG::2016-01-18 01:31:08,594::health::72::health::(_run) Health monitor started
Thread-13::DEBUG::2016-01-18 01:32:08,594::health::86::health::(_check) Checking health
Thread-13::DEBUG::2016-01-18 01:32:08,621::health::92::health::(_check_garbage) Collected 355 objects
Thread-13::DEBUG::2016-01-18 01:32:08,621::health::114::health::(_check_resources) user=0.20%, sys=0.05%, rss=50372 kB (+1172), threads=33
Thread-13::DEBUG::2016-01-18 01:33:08,622::health::86::health::(_check) Checking health
Thread-13::DEBUG::2016-01-18 01:33:08,640::health::92::health::(_check_garbage) Collected 9 objects
Thread-13::DEBUG::2016-01-18 01:33:08,640::health::114::health::(_check_resources) user=0.15%, sys=0.03%, rss=50540 kB (+168), threads=33
Thread-13::DEBUG::2016-01-18 01:34:08,642::health::86::health::(_check) Checking health
Thread-13::DEBUG::2016-01-18 01:34:08,669::health::92::health::(_check_garbage)
@nirs
nirs / health-after.log
Created January 18, 2016 00:01
after resourceref leak fix
MainThread::INFO::2016-01-18 01:00:21,551::health::60::health::(start) Starting health monitor (interval=60)
Thread-13::DEBUG::2016-01-18 01:00:21,559::health::72::health::(_run) Health monitor started
Thread-13::DEBUG::2016-01-18 01:01:21,559::health::86::health::(_check) Checking health
Thread-13::DEBUG::2016-01-18 01:01:21,576::health::92::health::(_check_garbage) Collected 375 objects
Thread-13::DEBUG::2016-01-18 01:01:21,576::health::114::health::(_check_resources) user=0.20%, sys=0.08%, rss=48396 kB (+1172), threads=33
Thread-13::DEBUG::2016-01-18 01:02:21,576::health::86::health::(_check) Checking health
Thread-13::DEBUG::2016-01-18 01:02:21,594::health::92::health::(_check_garbage) Collected 9 objects
Thread-13::DEBUG::2016-01-18 01:02:21,595::health::114::health::(_check_resources) user=0.13%, sys=0.03%, rss=48396 kB (+0), threads=33
Thread-13::DEBUG::2016-01-18 01:03:21,595::health::86::health::(_check) Checking health
Thread-13::DEBUG::2016-01-18 01:03:21,612::health::92::health::(_check_garbage) C
@nirs
nirs / sigprocmask.py
Last active August 29, 2015 14:06
Example of signal mask inheritance using python-signalfd package
from __future__ import print_function
import signal
import signalfd
import sys
import threading
def report():
mask = signalfd.sigprocmask(signalfd.SIG_BLOCK, [])
print('- pid: %s thread: %s mask: %s' % (
os.getpid(), threading.current_thread(), mask))
#include <unistd.h>
#include <zmq.h>
int main (int argc, char *argv[])
{
void *context = zmq_init (1);
void *socket = zmq_socket (context, ZMQ_PUB);
// Give some time for io thread to start
usleep(1000000);