Giter Club home page Giter Club logo

dshared's Introduction

dshared

A quick 'n dirty python extension providing shared memory dictionaries.

Summary

This extension creates a shared memory segment where (some) python values can be stored and accessed from distinct processes -- no IPC, no pickling/serializing, no wiring, not even locking will get in your way. Plain direct access to memory between parent/child processes. An uninteresting example:

import dshared
from multiprocessing import Process
dshared.init("mymem", 2 ** 10) #creates shared mem of size 2 ** 10

shm = dshared.dict()

def in_process_1():
  shm['d'] = {'key':'val'}

def later_on_in_process_2():
   print shm['d']['key']

p = Process(target=in_process_1)
p.start()
p.join()
p = Process(target=later_on_in_process_2)
p.start()
p.join()

important notes to keep in mind:

  • Currently, None, ints/longs, strings, dicts and lists can be stored in the shared memory. Dicts and lists may be recursive.

  • Instances of user defined classes are victims of evil voodoo when assigned to a shared dictionary (and so are the objects it points to! Somethings are just too wrong to be left unsaid).

  • This code was not written with reliability in mind -- far from it. And if you noticed there is no "tests" directory here, that should settle any crazy ideas related to putting this stuff in production environments.

  • There is no memory mechanism for collecting garbage (and it is unlikely that I will work on this). Once shared, forever lived.

  • Last but not least, I do not intend to maintain or improve this library, as it was written to fix a very particular and temporary problem. So, in the case you find this extension somehow useful and wish to fork/improve it, feel free to let me know so I can refer visitors of this repository to your repository.

Use it at your own risk, bla bla bla...Now that you have been warned:

List of dependencies

  • Python (I'm using 2.7.5)
  • boost libraries (in particular, Boost.Interprocess compatible with v. 1.54.0.1)
  • A C++ compiler and python's development files (headers, libraries, etc)

Installation on Debian-like systems

  • # aptitude install libboost-all-dev
  • # python setup.py install

dshared's People

Contributors

reqa avatar

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.