<file_sep>#define BOOST_PYTHON_STATIC_LIB 

#include <boost/python.hpp>
#include <boost/thread/thread.hpp>

extern double prog;<file_sep>svipul
======

Proof of concept of Python-Boost::Python two-way communication
<file_sep>from django.http import HttpResponse
from django.shortcuts import render
from django.http import HttpResponse
import svipul
from multiprocessing import Process

progress = 0.0

import threading

class SummingThread(threading.Thread):
     def run(self):
         svipul.work()

def home(request):
    # View code here...
    return render(request, 'index.html', {})


def work(request):
    progress = 0.0
    #svipul.work()
    p = SummingThread()
    p.start()
    p.join()
    return HttpResponse('done')

def prog(request):
    return HttpResponse(str(progress))

def incr_prog():
    global progress
    progress += 1.0


def f(name):
    print 'hello', name
<file_sep>#include "main.hpp"

double prog = 0.0;

double get_prog()
{
	return prog;
}

void work()
{
	using namespace boost;
	python::object views(( 
        python::handle<>( 
            python::borrowed(PyImport_AddModule("svipul.views")))));
	python::object incr_prog = views.attr("incr_prog"); 
	prog = 0.0;
	for(int i = 0; i < 30; ++i)
	{
	    boost::this_thread::sleep(boost::posix_time::seconds(1));
		prog = i/30.0;
		std::cout << prog << std::endl;
		incr_prog();
	}
}

BOOST_PYTHON_MODULE(svipul)
{
    using namespace boost::python;
    def("work", work);
	scope().attr("prog") = prog;
    def("get_prog", get_prog);
}<file_sep> # -*- coding: utf-8 -*-

from bottle import route, run, template, view, static_file
import os.path
import svipul

from multiprocessing import Process

SITE_ROOT = os.path.dirname(os.path.realpath(__file__))

def work():
    svipul.work()

@route('/')
@view('index')
def index():
    return dict()

@route('/work')
def work():
    svipul.work()
    return "done"

@route('/prog')
def work():
    return str(svipul.get_prog())

@route('/static/<filename:path>')
def send_static(filename):
    return static_file(filename, root=os.path.join(SITE_ROOT, 'static'))

run(host='localhost', port=8080, reloader=True, server='cherrypy')<file_sep>from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    url(r'^$', 'svipul.views.home', name='home'),
    url(r'work$', 'svipul.views.work', name='work'),
    url(r'prog$', 'svipul.views.prog', name='prog'),
    # url(r'^svipul/', include('svipul.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
)

urlpatterns += staticfiles_urlpatterns()