示例#1
0
    def __init__(self, *args):
        super(B2BucketThreaded, self).__init__(*args)

        num_threads = 50
        self.queue = LifoQueue(num_threads * 2)

        self.file_locks = defaultdict(Lock)

        self.running = True

        self.threads = []
        print "Thread ",
        for i in xrange(num_threads):
            t = threading.Thread(target=self._file_updater)
            t.start()
            self.threads.append(t)

            print ".",

        print

        self.pre_queue_lock = Lock()
        self.pre_queue_running = True
        self.pre_queue = LifoQueue(num_threads * 2)

        self.pre_file_dict = {}

        self.pre_thread = threading.Thread(target=self._prepare_update)
        self.pre_thread.start()
示例#2
0
        def __init__(self, url):
            # Direct class call `threading.Thread` instead of `super()` for python2 capability
            threading.Thread.__init__(self)
            self.lv_url = url
            self._lilo_head_pool = LifoQueue()
            self._lilo_jpeg_pool = LifoQueue()

            self.header = None
            self.frameinfo = []
示例#3
0
 def _onSizeChanged(self):
     self._cache = _TilesCache(self._current_stack_id,
                               self._sims,
                               maxstacks=self._cache_size)
     self._dirtyLayerQueue = LifoQueue(self._request_queue_size)
     self._prefetchQueue = Queue(self._request_queue_size)
     self.sceneRectChanged.emit(QRectF())
示例#4
0
def inToPost(expr):
    ''' 
    takes as input an infix expression and outputs a post fix expression
    '''
    result = []
    stack = LifoQueue(maxsize=len(expr))
    #loop iterates over every character in the expression
    for char in expr:
        # non variables are put on a stack where their precedence will determine the order of transfer onto the result queue
        if (Helper.isOp(char) or char == '!'):
            if (stack.empty() or Helper.peek(stack) == '('): stack.put(char)
            elif (Helper.precedence(Helper.peek(stack)) >
                  Helper.precedence(char)):
                result.append(stack.get())
                stack.put(char)
            elif (Helper.precedence(
                    Helper.peek(stack)) == Helper.precedence(char)):
                result.append(char)
            else:
                stack.put(char)
        elif (char == '('):
            stack.put(char)
            # consecutively adding operators between operators on result
        elif (char == ')'):
            while (not Helper.peek(stack) == '('):
                result.append(stack.get())
            stack.get()
        # Variables are directly put on result
        else:
            result.append(char)
    # remaining character on the stack are consecutively added to result
    while (not stack.empty()):
        result.append(stack.get())
    return result
示例#5
0
    def __create_gui(self):

        # Add subplots
        self.figure = Mat_figure(figsize=(5, 3), dpi=100)
        self.subplotTop = self.figure.add_subplot(211)
        self.subplotBottom = self.figure.add_subplot(212)

        # Add labels
        self.subplotTop.set_xlabel('Frames')
        self.subplotBottom.set_xlabel('Hz')
        # Change font size
        matplotlib.rcParams.update({'font.size': 10})

        # Create canvas
        self.canvas = FigureCanvasTkAgg(self.figure, master=self.root)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        # We store the data that is interchanged from GuiSignalProcessor to GuiSignalPlotter in a queue
        self.dataQueue = LifoQueue()

        # Create thread that displays signal
        self.signalPlotThread = GuiSignalPlotter(
            self.root, self.cameraInstance, self.figure, self.canvas,
            self.subplotTop, self.subplotBottom, self.statusbar,
            self.video_display, self.dataQueue)
        # Create thread that processes signal
        self.signalProcessorThread = GuiSignalProcessor(
            self.root, self.cameraInstance, self.figure, self.canvas,
            self.subplotTop, self.subplotBottom, self.statusbar,
            self.video_display, self.dataQueue)

        # Start both threads
        self.signalPlotThread.start()
        self.signalProcessorThread.start()
示例#6
0
def getPath(startingPrime, finalPrime):
    # print(type(startingPrime))
    # print("starting Prime: " + str(startingPrime))
    # print(type(finalPrime))
    # print("final Prime: " + str(finalPrime))

    # your code here
    #depth limit is 5
    #declare stack
    closedList.clear()
    stack = LifoQueue()

    #push <startingPrime (currentPrime), 0 (depth)> into the stack
    stack.put((startingPrime, 0))

    outputString = ""

    #while stack is not empty
    while (not stack.empty()):
        #pop a from stack
        a = stack.get()

        #if a.currentPrime == finalPrime
        if (a[0] == finalPrime):
            break

#else if a.depth >= 5
        elif (a[1] >= 5):
            continue

#find all neighbor of currentPrime
        neighbor = getPossibleActions(a[0])

        for i in range(0, len(neighbor)):
            #set the parent of the neighbor to currentPrime
            closedList[str(neighbor[i])] = a[0]
            #push all neighbor as <neighbor,a.depth + 1> into the stack
            stack.put((neighbor[i], a[1] + 1))

    #if(currentPRime != finalPrime)
    if (a[0] != finalPrime):
        #unsolvable
        outputString = 'UNSOLVABLE'

    else:
        current = a[0]
        outputString = ""
        outputString = str(current) + " " + outputString
        while (current != startingPrime):
            current = closedList[str(current)]
            outputString = str(current) + " " + outputString


# 		outputString = startingPrime + " " + outputString

#     file = open('output.txt','w')
#     print >> file,outputString
#     file.close()
    sys.stdout.write(outputString + "\n")
    return
def varnish_object_stream_prepare(obj):
    obj._name_check()
    host, uri = varnish_rewrite(obj)
    headers = {
        'User-Agent': "swiftrepl",
        'If-Cached': obj.etag
    }

    try:
        varnish_object_stream_prepare.queue
    except AttributeError:
        varnish_object_stream_prepare.queue = LifoQueue(maxsize=256)

    try:
        connection, t = varnish_object_stream_prepare.queue.get(False)
        if time.time() - t > 3:
            raise Empty()
    except Empty:
        connection = httplib.HTTPConnection(host, port=80, timeout=10)

    connection.request('GET', uri, None, headers)
    response = connection.getresponse()
    if response.status < 200 or response.status > 299:
        buff = response.read()
        try:
            varnish_object_stream_prepare.queue.put((connection, time.time()), False)
        except Full:
            del connection
        raise cloudfiles.errors.ResponseError(response.status, response.reason)
    return response, connection
示例#8
0
    def __init__(self, speech_state_machine):

        # Speech sampler
        self.__fs = 16000
        self.__sampler_window_duration = 5 # seconds
        self.__sampler = Speech_Sampler(self.__sampler_window_duration, self.__fs)

        # Feature builder
        self.__feature_window_duration = 0.025 # seconds
        self.__feature_skip_duration = 0.01 # seconds
        self.__feature_nfilters = 26
        self.__feature_nfilters_keep = 13
        self.__feature_radius = 2
        self.__feature_builder = ASR_Feature_Builder()

        # Processing
        self.__ignore_sample = False
        self.__max_queue_size = 10
        self.__pool = multiprocessing.Pool()
        self.__process_sleep_time = 0.025 # seconds
        self.__queue_lock = threading.Lock()
        self.__plot_option = -1
        self.__speech_segments = LifoQueue()
        self.__speech_state_machine = speech_state_machine
        self.__stop_processing = False

        self.__feature_builder.set_plot_blocking(True)
        self.__sampler.add_sample_callback(self.__queue_speech_segment)
        self.__sampler.hide_spectrogram_plot()
        self.__sampler.hide_zero_crossing_plot()
        self.__speech_state_machine.add_speech_match_callback(self.__speech_matched)
示例#9
0
def upload(root_path, bucket, aws_id, aws_key):

	max_workers = 20
	q = LifoQueue(maxsize=5000)

	for i in range(max_workers):
		print 'Adding worker thread %s for queue processing' % i
		t = Worker(q, i, bucket, root_path, aws_id, aws_key)
		t.daemon = True
		t.start()

	total = 0
	# https://docs.python.org/2/library/os.html
	for root, dirs, files in os.walk(root_path):
		for name in files:
			relative = root.split(root_path + os.sep)[1]
			path = os.path.join(relative, name)
			#print 'Adding %s to the queue' % path
			q.put(path)
			total += 1

			while q.qsize() > (q.maxsize - max_workers):
				time.sleep(10)  # sleep if our queue is getting too big for the next set of keys

	print 'Waiting for queue to be completed'
	q.join()

	print 'Done'
示例#10
0
    def __init__(self, car):
        self.actions = ('forward', 'stop')  #, 'forwardLeft') #, 'backward')
        self.car = car
        self.cameras_size = 3 * 32 * 24
        self.sensors_size = 3
        self.state_size = self.cameras_size + self.sensors_size  # 3 cameras + 3 sensors
        self.taken_actions = LifoQueue()

        self.reward_sensor = -10
        self.reward_step = 0.3
        self.reward_goal = 100

        df = pd.read_csv("dataset.csv", usecols=[1, 2])
        df = np.array(df)

        self.X = []
        self.y = []

        for data in df:
            target = data[1]
            images = self.read_img(data[0])

            self.X.append(images)
            self.y.append(target)

        self.dataset_count = len(self.X)

        self.dataset_index = 0
示例#11
0
def dfs_post_nonrec(tree, proc):
    '''
    非递归后根序遍历
    :param tree:
    :param proc:
    :return:
    '''
    stack = LifoQueue()
    node = tree
    while node is not None or not stack.empty():
        while node is not None:  # 注意,这一波遍历的规则是能左则左,若不能左往右也行
            stack.put(node)
            if node.left is not None:
                node = node.left
            else:
                node = node.right

        node = stack.get()  # 这个算法的特征之一,处理某个节点的时候,栈中保存着的是这个节点的所有前辈节点
        proc(node.data)

        #### 从这里开始和中根序遍历不一样 ####
        if stack.empty():  # 若栈空,说明当前节点没有任何前辈节点,即根节点。根节点处理完成后直接跳出程序
            break

        tmp = stack.get()  # 由LifoQueue实现的栈没有peek或者top方法,自己模拟一下…
        stack.put(tmp)

        if node is tmp.left:  # 判断刚才处理的是左子节点还是右子节点
            node = tmp.right  # 左子节点的话说明右子节点还没处理
        else:
            node = None  # 右子节点的话说明tmp节点对应子树已经处理完了
示例#12
0
    def __init__(self, poolableFactory, **config):
        from Queue import Queue, LifoQueue

        self.__dict__.update(config)
        logging.debug(config)
        logging.debug(self)
        if self.lifo:
            self._pool = LifoQueue(self.maxActive)
            logging.debug("create a lifo queue.")
        else:
            self._pool = Queue(self.maxActive)  # create the queue
            logging.debug("create a FIFO queue.")

        self.poolableFactory = poolableFactory

        try:
            logging.info("Init {0} objects for pool.".format(self.maxIdle))
            for i in range(self.maxIdle):
                self.put(self.poolableFactory.create())
            logging.info("Inited {0} objects for pool.".format(self.maxIdle))
            self._available = True
            if self.timeBetweenEvictionRunsMillis > 0:
                #                 self.__startCheckThread()
                pass
        except Exception, e:
            raise e
示例#13
0
文件: save.py 项目: kba/calibre
 def __init__(self, parent, notify=None):
     QObject.__init__(self, parent)
     self.count = 0
     self.last_saved = -1
     self.requests = LifoQueue()
     self.notify_requests = LifoQueue()
     self.notify_data = notify
     t = Thread(name='save-thread', target=self.run)
     t.daemon = True
     t.start()
     t = Thread(name='notify-thread', target=self.notify_calibre)
     t.daemon = True
     t.start()
     self.status_widget = w = SaveWidget(parent)
     self.start_save.connect(w.start, type=Qt.QueuedConnection)
     self.save_done.connect(w.stop, type=Qt.QueuedConnection)
示例#14
0
 def __init__(self, args, num=0, **kw):
     """Starts a set of processes, defined by num:
         if num is an int:
             > 0: that many procs
             <= 0: getNumCPUs() - num
         elif num is a float:
             that percentage of cpus of this sys
     Any additional kw args are passed to the initializer for Process().
     (These are the same as the inputs to subprocess.Popen())
     """
     from threading import Lock
     from copy import deepcopy
     from Queue import Queue, LifoQueue
     from nkthreadutils import spawnWorkers
     from nkutils import parseNProcs
     self.nprocs = nprocs = parseNProcs(num)
     self.args = deepcopy(args)  # in case we alter them
     # spawn processes and associated locks and working queues
     self.procs = [Process(args, **kw) for i in range(nprocs)]
     self.proclocks = [Lock() for p in self.procs]
     self.working = [LifoQueue() for p in self.procs]
     # spawn instance vars to track inputs and results
     self.inq = Queue()
     self.results = {}
     self.resultlock = Lock()
     # spawn worker threads
     self.inloop = spawnWorkers(1, self.inputloop)[0]
     self.outloop = spawnWorkers(1, self.outputloop)[0]
示例#15
0
    def __init__(self, canvas):

        self.providers = {
            'Bing': self.bing_setup,
            'ArcGIS': self.arcgis_setup,
            'MapQuest': self.mq_setup
        }

        self.canvas = canvas
        self.imageryprovider = None
        self.provider_base = None
        self.provider_url = None
        self.provider_logo = None  # (filename, width, height)
        self.provider_levelmin = self.provider_levelmax = 0
        self.placementcache = {
        }  # previously created placements (or None if image couldn't be loaded), indexed by quadkey.
        # placement may not be laid out if image is still being fetched.
        self.tile = (0, 999)  # X-Plane 1x1degree tile - [lat,lon] of SW
        self.loc = None
        self.dist = 0

        self.filecache = Filecache()

        # Setup a pool of worker threads
        self.workers = []
        self.q = LifoQueue()
        for i in range(Imagery.connections):
            t = threading.Thread(target=self.worker)
            t.daemon = True  # this doesn't appear to work for threads blocked on Queue
            t.start()
            self.workers.append(t)
示例#16
0
 def _visit(self, node, pre_action=None, post_action=None):
     """Explore the connected component,"""
     self.time = self.time + 1
     self.dd[node] = self.time
     self.color[node] = "GREY"
     Q = LifoQueue()
     Q.put(node)  # node is GREY
     if pre_action:  # when Q.put
         pre_action(node)
     while not Q.empty():
         source = Q.get()  # GREY node is processed
         for edge in self.graph.iteroutedges(source):
             if self.color[edge.target] == "WHITE":
                 self.parent[edge.target] = source
                 self.dag.add_edge(edge)
                 self.time = self.time + 1
                 self.dd[edge.target] = self.time
                 self.color[edge.target] = "GREY"
                 Q.put(edge.target)  # target is GREY
                 if pre_action:  # when Q.put
                     pre_action(edge.target)
         self.time = self.time + 1
         self.ff[source] = self.time
         self.color[source] = "BLACK"
         if post_action:  # source became BLACK
             post_action(source)
    def pushGoals(self,mapNode,start,markerArray,isreverted,isPathOnService):
        # x=round(int(target['x'])/float(self.RESOLUTION*0.5),0)
        # y=round(int(target['y'])/float(self.RESOLUTION*0.5),0)
        revert=[]
        x=start['x']
        y=start['y']
        # goalQueue=LifoQueue()
        goalQueue=Queue()
        goalLifo=LifoQueue()
        goalQueue.put(self.createGoal(x,y))
        try:
                prev=mapNode[str(int(x))+'_'+str(int(y))]
                # FIXME TO CHECK NONE VALUE
                while prev != None:

                    # x=round(int(prev.split('_')[0])/float(self.RESOLUTION*0.5),0)
                    # y=round(int(prev.split('_')[1])/float(self.RESOLUTION*0.5),0)
                    print 'GOAL -->'+prev
                    x=int(prev.split('_')[0])
                    y=int(prev.split('_')[1])
                    currentgoal=self.createGoal(x,y)
                    self.createGoalMarker(currentgoal,markerArray,x,y)
                    rospy.sleep(0.01)
                    goalQueue.put(currentgoal)
                    prev=mapNode[str(x)+'_'+str(y)]
        except KeyError, e:
                print 'end reverse path'
示例#18
0
 def _find_path_dfs(self):
     """Finding augmenting paths in the residual network."""
     parent = dict((node, None) for node in self.residual.iternodes())
     # Capacity of found path to node.
     capacity = {self.source: float("inf")}
     Q = LifoQueue()
     Q.put(self.source)
     while not Q.empty():
         node = Q.get()
         for edge in self.residual.iteroutedges(node):
             cap = edge.weight - self.flow[edge.source][edge.target]
             if cap > 0 and parent[edge.target] is None:
                 parent[edge.target] = edge.source
                 capacity[edge.target] = min(capacity[edge.source], cap)
                 if edge.target != self.sink:
                     Q.put(edge.target)
                 else:
                     # Backtrack search and write flow.
                     target = self.sink
                     while target != self.source:
                         node = parent[target]
                         self.flow[node][target] += capacity[self.sink]
                         self.flow[target][node] -= capacity[self.sink]
                         target = node
                     return capacity[self.sink]
     return 0
示例#19
0
    def __init__(self):
        self.last_timestamp = None
        # the variance used in the matrix Q
        self.process_variance = rospy.get_param(
            "/kalman_filter_node/process_variance", 100)
        # the variance used in the matrix R for the GPS measurements
        self.gps_variance = rospy.get_param("/kalman_filter_node/gps_variance",
                                            0.1)
        # the variance used in the matrix R of the pressure altitude measurements
        self.pressure_variance = rospy.get_param(
            "/kalman_filter_node/pressure_variance", 0.1)
        #  the variance used in the matrix R of the vertical velocity measurements
        self.velocity_variance = rospy.get_param(
            "/kalman_filter_node/velocity_variance", 0.1)

        self.queue = LifoQueue()

        self.sub_pa = rospy.Subscriber('/uav/sensors/pressure_altitude',
                                       AltitudeStamped,
                                       self.process_pressure_altitude,
                                       queue_size=1)
        self.sub_gps_a = rospy.Subscriber('/uav/sensors/gps_altitude',
                                          AltitudeStamped,
                                          self.process_gps_altitude,
                                          queue_size=1)
        self.sub_vel = rospy.Subscriber('/uav/sensors/velocity',
                                        TwistStamped,
                                        self.process_velocity,
                                        queue_size=1)
        self.pub = rospy.Publisher('/uav/sensors/kalman_filter_altitude',
                                   AltitudeStamped,
                                   queue_size=1)
        self.mainloop()
def copyBucket(maxKeys=1000):
    print 'start'

    conn = S3Connection(aws_key, aws_secret_key)
    srcBucket = conn.get_bucket(srcBucketName)

    resultMarker = ''
    q = LifoQueue(maxsize=5000)

    for i in range(10):
        print 'adding worker'
        t = Worker(q)
        t.daemon = True
        t.start()

    while True:
        print 'fetch next 1000, backlog currently at %i' % q.qsize()
        keys = srcBucket.get_all_keys(max_keys=maxKeys, marker=resultMarker)
        for k in keys:
            q.put(k.key)
        if len(keys) < maxKeys:
            print 'Done'
            break
        resultMarker = keys[maxKeys - 1].key

    q.join()
    print 'done'
示例#21
0
 def run(self):
     if not self.saveinput():
         return
     env = os.environ.copy()
     env['OMMPROTOCOL_SLAVE'] = '1'
     env['PYTHONIOENCODING'] = 'latin-1'
     self.task = Task("OMMProtocol for {}".format(self.filename),
                      cancelCB=self._clear_cb,
                      statusFreq=((1, ), 1))
     self.subprocess = Popen(
         ['ommprotocol', self.filename],
         stdout=PIPE,
         stderr=PIPE,
         progressCB=self._progress_cb,  #universal_newlines=True,
         bufsize=1,
         env=env)
     self.progress = SubprocessTask("OMMProtocol",
                                    self.subprocess,
                                    task=self.task,
                                    afterCB=self._after_cb)
     self.task.updateStatus("Running OMMProtocol")
     self.queue = LifoQueue()
     thread = Thread(target=enqueue_output,
                     args=(self.subprocess.stdout, self.queue))
     thread.daemon = True  # thread dies with the program
     thread.start()
     self.ensemble = _TrajProxy()
     self.molecule = self.ensemble.molecule = self.gui.ui_chimera_models.getvalue(
     )
     self.ensemble.name = 'Trajectory for {}'.format(self.molecule.name)
     self.ensemble.startFrame = self.ensemble.endFrame = 1
     self.movie_dialog = MovieDialog(self.ensemble, externalEnsemble=True)
     self.gui.Close()
示例#22
0
 def __init__(self, graph):
     """The algorithm initialization."""
     self.graph = graph
     if not self._is_eulerian():
         raise ValueError("the graph is not eulerian")
     self.eulerian_cycle = list()
     self._graph_copy = self.graph.copy()
     self._stack = LifoQueue()
示例#23
0
 def set_defaults(self):
     self.cfg["BUND_HOME"] = "/tmp"
     self.cfg["BUND_REF_BASE"] = self.RefBase
     self.cfg["BUND_ENV_NAME"] = "default"
     self.cfg["BUND_MAX_PIPELINE"] = 100
     self.cfg["BUND_MAX_ENV_STACK"] = 100
     self.cfg["BUND_VERBOSE"] = 0
     self.cfg["BUND_UNSAFE_GLOBALS"] = False
     self.envs = LifoQueue(self.cfg["BUND_MAX_ENV_STACK"])
示例#24
0
    def pushGoals(self, mapNode, start, marker_container, isreverted,
                  isPathOnService):
        # x=round(int(target['x'])/float(self.RESOLUTION*0.5),0)
        # y=round(int(target['y'])/float(self.RESOLUTION*0.5),0)
        revert = []
        x = start['x']
        y = start['y']
        # goalQueue=LifoQueue()
        goalQueue = Queue()
        goalLifo = LifoQueue()
        goalQueue.put(self.createGoal(x, y))
        try:
            prev = mapNode[str(int(x)) + '_' + str(int(y))]
            # FIXME TO CHECK NONE VALUE
            while prev != None:
                # x=round(int(prev.split('_')[0])/float(self.RESOLUTION*0.5),0)
                # y=round(int(prev.split('_')[1])/float(self.RESOLUTION*0.5),0)
                print('GOAL -->' + prev)
                x = int(prev.split('_')[0])
                y = int(prev.split('_')[1])
                currentgoal = self.createGoal(x, y)
                self.createGoalMarker(currentgoal, marker_container, x, y)
                # rospy.sleep(0.01)
                goalQueue.put(currentgoal)
                prev = mapNode[str(x) + '_' + str(y)]
        except KeyError as e:
            print('end reverse path')
        self.pub_marker.publish(marker_container)

        if (isreverted):
            while not goalQueue.empty():
                goalLifo.put(goalQueue.get())
            while not goalLifo.empty():
                goalQueue.put(goalLifo.get())

        if isPathOnService:

            ### TODO
            ### call here the local planner service (self.local_planner_service)
            ### goalQueue: queue of goal to acheive (Posestamped ros message)
            ###
            ### self.local_planner_service: service to call the local planner ( TODO need to be created on the ShortPathMng constructor)
            #
            #
            #
            #
            #                       TODO
            #
            #
            #
            #
            ###
            print('')
        else:
            while not goalQueue.empty():
                self.pub_goal.publish(goalQueue.get())
                rospy.sleep(2)
示例#25
0
    def __init__(self, name, topic, msgtype, verbose=False):
        self.topic = topic
        self.msgtype = msgtype
        self.name = name

        self.bridge = CvBridge()
        self.convertor = self.convertor_query()
        self.verbose = verbose
        self.subthread = None
        self.ros_image = LifoQueue(maxsize=5)
示例#26
0
def DFS(N, L, root):
    queue = LifoQueue()
    queue.put_nowait(root)
    while queue.qsize() != 0:
        arrangement = queue.get_nowait()
        if arrangement.L == L:
            return arrangement.Map
        else:
            search(N, arrangement, queue)
    return 0
示例#27
0
    def __init__(self):
        # Queue holding the last speech utterance
        self._speak_queue = LifoQueue(1)

        self._session = Session(profile_name="mylespolly")
        self._polly = self._session.client("polly", region_name="eu-west-1")

        self._thread = Thread(target=self.run, args=())
        self._thread.daemon = True
        self._thread.start()
示例#28
0
 def __init__(self, parent):
     super(CoverDelegate, self).__init__(parent)
     self._animated_size = 1.0
     self.animation = QPropertyAnimation(self, 'animated_size', self)
     self.animation.setEasingCurve(QEasingCurve.OutInCirc)
     self.animation.setDuration(500)
     self.set_dimensions()
     self.cover_cache = CoverCache(limit=gprefs['cover_grid_cache_size'])
     self.render_queue = LifoQueue()
     self.animating = None
     self.highlight_color = QColor(Qt.white)
示例#29
0
 def __init__(self, graph):
     """The algorithm initialization."""
     self.graph = graph
     if not self._is_eulerian():
         raise ValueError("the graph is not eulerian")
     self.eulerian_cycle = list()
     self._graph_copy = self.graph.copy()
     self._stack = LifoQueue()
     import sys
     recursionlimit = sys.getrecursionlimit()
     sys.setrecursionlimit(max(self.graph.v()**2, recursionlimit))
示例#30
0
 def __init__(self, conn, addr, s_container):
     Thread.__init__(self)
     self.conn = conn
     self.conn.settimeout(1.0)
     self.addr = addr
     self.scenarios = LifoQueue()
     self.current_scenario = None
     self.stop = False
     self.scenario_stop = False
     self.buffer = array("B")
     self.packet_len = 0