Commit 57bf8c44 authored by Swann Perarnau's avatar Swann Perarnau
Browse files

Fix imports for binaries

Use the binaries to make sure that the imports work. There's probably
still some weird things in there, but it's a start.
parent 2d36fbe9
#!/usr/bin/env python3
import traceback
import cProfile
import getopt
import time
import json
import sys
import signal
import threading
from erebor import FrameworkControler
from erebor import Erebor
from isengard import consts
import yggdrasil
from yggdrasil.erebor import Erebor
def flushprint(*args, **kwargs):
print(*args, file=sys.stdout, **kwargs)
sys.stdout.flush()
def main(argv, Controler=None):
flushprint("start")
try:
......@@ -79,12 +75,12 @@ def main(argv, Controler=None):
signal.signal(signal.SIGINT, signal_handler)
if root :
if root:
controler = Controler(erebor, ID, hlist, tfile)
# Start the test sample after the root network bootstrap
erebor.on_network_init(ID, controler.start)
controler.bootstrap()
else :
else:
erebor.bootstrap(ID)
erebor.process_messages()
except:
......@@ -92,5 +88,7 @@ def main(argv, Controler=None):
#traceback.print_exception(sys.exc_info())
erebor.terminate()
sys.exit(-1)
if __name__ == "__main__":
sys.exit(main(sys.argv))
......@@ -10,7 +10,8 @@ import struct
import sys
import socket
import select
from isengard import consts
import yggdrasil
from yggdrasil.isengard import consts
from threading import Thread
from threading import Timer
from threading import Lock
......
from ereborc import Erebor
from encoder import MPIDecoder
from network import Network
from framework import FrameworkControler
from main import main
from .ereborc import Erebor
from .encoder import MPIDecoder
from .network import Network
from .framework import FrameworkControler
#!/usr/bin/env python3
import sys
import struct
from isengard import consts
from ..isengard import consts
class MPIDecoder:
......
......@@ -13,13 +13,12 @@ import queue
import multiprocessing
from threading import Lock
from threading import RLock
from isengard import flushp
from isengard import consts
from isengard import Helper
from network import Network
from rwlock import RWLock
from consts import bcolors
from mpibridge import MPIHook
from ..isengard import flushp
from ..isengard import consts
from ..isengard import Helper
from .network import Network
from ..isengard.consts import bcolors
from .mpibridge import MPIHook
class CallbackObject:
def __init__(self, dnode, dnetid, snode, snetid, callback, value):
......
......@@ -2,8 +2,7 @@ import time
import json
import sys
import os.path
from erebor import Erebor
from isengard import consts
from ..isengard import consts
class FrameworkControler:
......
......@@ -2,11 +2,11 @@ import getopt
import sys
import json
import zmq
from isengard import consts
from encoder import MPIDecoder
from ..isengard import consts
from .encoder import MPIDecoder
from threading import Thread
from isengard import flushp
from isengard.socket_bridge import Bridge
from ..isengard import flushp
from ..isengard.socket_bridge import Bridge
class Event :
def __init__(self, f, data) :
......
......@@ -4,10 +4,10 @@ import time
import re
import signal
import json
from isengard import flushp
from isengard import consts
from isengard.isengardc import Isengard
from isengard.consts import bcolors
from ..isengard import flushp
from ..isengard import consts
from ..isengard.isengardc import Isengard
from ..isengard.consts import bcolors
class Network(Isengard) :
......
"""
Synchronization primitives:
- reader-writer lock (preference to writers)
(Contributed to Django by eugene@lazutkin.com)
source :
https://hdknr.github.io/docs/django/modules/django/utils/synch.html#RWLock
"""
import threading
class RWLock():
"""
Classic implementation of reader-writer lock with preference to writers.
Readers can access a resource simultaneously.
Writers get an exclusive access.
API is self-descriptive:
reader_enters()
reader_leaves()
writer_enters()
writer_leaves()
"""
def __init__(self):
self.mutex = threading.RLock()
self.can_read = threading.Semaphore(0)
self.can_write = threading.Semaphore(0)
self.active_readers = 0
self.active_writers = 0
self.waiting_readers = 0
self.waiting_writers = 0
def reader_enters(self):
with self.mutex:
if self.active_writers == 0 and self.waiting_writers == 0:
self.active_readers += 1
self.can_read.release()
else:
self.waiting_readers += 1
self.can_read.acquire()
def reader_leaves(self):
with self.mutex:
self.active_readers -= 1
if self.active_readers == 0 and self.waiting_writers != 0:
self.active_writers += 1
self.waiting_writers -= 1
self.can_write.release()
def reader(self):
self.reader_enters()
try:
yield
finally:
self.reader_leaves()
def writer_enters(self):
with self.mutex:
if self.active_writers == 0 and self.waiting_writers == 0 and self.active_readers == 0:
self.active_writers += 1
self.can_write.release()
else:
self.waiting_writers += 1
self.can_write.acquire()
def writer_leaves(self):
with self.mutex:
self.active_writers -= 1
if self.waiting_writers != 0:
self.active_writers += 1
self.waiting_writers -= 1
self.can_write.release()
elif self.waiting_readers != 0:
t = self.waiting_readers
self.waiting_readers = 0
self.active_readers += t
while t > 0:
self.can_read.release()
t -= 1
def writer(self):
self.writer_enters()
try:
yield
finally:
self.writer_leaves()
from flushp import flushprint
from consts import *
from consts import bcolors
from isengardc import Isengard
from isengardc import Helper
from isengardc import Event
from unix_socket_wrapper import Unix_socket
from taktuk_wrapper import Wrapper
from .flushp import flushprint
from .consts import *
from .consts import bcolors
from .isengardc import Isengard
from .isengardc import Helper
from .isengardc import Event
from .unix_socket_wrapper import Unix_socket
from .taktuk_wrapper import Wrapper
......@@ -5,14 +5,14 @@ import re
import sys
import queue
import multiprocessing
import flushp
from . import flushp
from threading import Lock
from threading import Timer
from isengard import consts
from isengard.unix_socket_wrapper import Unix_socket
from isengard.socket_bridge import Bridge
from isengard.taktuk_wrapper import Wrapper
from isengard.consts import bcolors
from . import consts
from .unix_socket_wrapper import Unix_socket
from .socket_bridge import Bridge
from .taktuk_wrapper import Wrapper
from .consts import bcolors
HOST = 0
PEER = 1
......
......@@ -10,7 +10,7 @@ import struct
import sys
import socket
import select
from isengard import consts
from . import consts
from threading import Thread
from threading import Timer
from threading import Lock
......
import sys
import collections
import pexpect
import flushp
from isengard import consts
from . import flushp
from . import consts
from threading import Thread
# Class Wrapper
......
......@@ -5,8 +5,8 @@ import select
import queue
import socket
import os
import flushp
from isengard import consts
from . import flushp
from . import consts
from threading import Lock
from threading import Thread
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment