本文整理汇总了Python中afqueue.common.exception_formatter.ExceptionFormatter.get_full_exception方法的典型用法代码示例。如果您正苦于以下问题:Python ExceptionFormatter.get_full_exception方法的具体用法?Python ExceptionFormatter.get_full_exception怎么用?Python ExceptionFormatter.get_full_exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类afqueue.common.exception_formatter.ExceptionFormatter
的用法示例。
在下文中一共展示了ExceptionFormatter.get_full_exception方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_command
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def run_command(message, reply_message_type):
try:
# Create the ZMQ context.
zmq_context = zmq.Context(1)
# Form return dictionary.
results_dict = dict()
# Issue the command to each IP/Port combination we were given.
for address in parsed_arguments.address.split(","):
# Split the IP and port.
split_data = address.split(":")
bridge_ip = split_data[0]
bridge_port = split_data[1]
# Get the connection string and create the socket connection.
connection_string = ZmqUtilities.get_socket_connection_string(bridge_ip, bridge_port)
remote_request_socket = zmq_context.socket(zmq.REQ)
remote_request_socket.setsockopt(zmq.LINGER, 0)
remote_request_socket.connect(connection_string)
try:
# Send and wait for a reply.
print("Sending message: {0}".format(message))
message.send(remote_request_socket)
# Get the message; initialize to not handled.
print("Waiting for reply...")
raw_message = SocketWrapper.pull_message(remote_request_socket)
# Path off command.
reply_message = reply_message_type.create_from_received(raw_message)
if int(reply_message.response_code) >= 500:
raise Exception("Error code returned. Reply: {0}".format(reply_message))
#
results_dict[address] = reply_message
except:
raise ExceptionFormatter.get_full_exception()
finally:
# Destroy our socket.
remote_request_socket.setsockopt(zmq.LINGER, 0)
remote_request_socket.close()
# Return results.
return results_dict
except:
raise ExceptionFormatter.get_full_exception()
示例2: stop_and_remove_bridge_workers_by_connection_string
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def stop_and_remove_bridge_workers_by_connection_string(self, connection_string, count):
try:
# For each count given.
for _ in range(count):
# Get the remaining workers; if we have none left, return out.
bridge_worker_list = self._connection_string_workers_map.get(connection_string, list())
if len(bridge_worker_list) == 0:
return
# Get the bridge worker.
bridge_worker = bridge_worker_list[0]
# Shut down the bridge worker.
bridge_worker.should_shutdown = True
bridge_worker.action_queue.put(system_messages.SystemStopThreadMessage(), False)
bridge_worker.process.join()
# Remove the bridge worker from our list.
self._connection_string_workers_map[connection_string].remove(bridge_worker)
except:
raise ExceptionFormatter.get_full_exception()
示例3: _handle_system_bridge_worker_timed_out
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def _handle_system_bridge_worker_timed_out(self, message):
"""
"""
try:
# Log.
self.logger.log_error("Received bridge worker timed out: {0}. Stopping and removing bridge worker thread from tracking.".format(message.thread_name))
# Kill.
bridge_worker = self._bridge_worker_manager.stop_and_remove_bridge_worker_by_thread_name(message.thread_name)
# If no bridge worker was returned, denote.
if bridge_worker == None:
self.logger.log_error("No bridge worker found for given thread name: {0}.".format(message.thread_name))
# If a thread worker was found, handle the removed bridge worker due to the time out.
else:
# Register the bridge worker's connection string in our recreation tracker.
if bridge_worker.connection_string not in list(self._worker_recreation_tracker_dict.keys()):
self._worker_recreation_tracker_dict[bridge_worker.connection_string] = 0
self._worker_recreation_time_stamp_dict[bridge_worker.connection_string] = list()
self._worker_recreation_tracker_dict[bridge_worker.connection_string] = self._worker_recreation_tracker_dict[bridge_worker.connection_string] + 1
# Return that we successfully handled the message.
return True
except:
raise ExceptionFormatter.get_full_exception()
示例4: stop_and_remove_bridge_worker_by_thread_name
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def stop_and_remove_bridge_worker_by_thread_name(self, thread_name):
"""
Finds the bridge worker with the given thread name.
Denotes the worker should shut down, ensures it is stopped/stopping via a stop thread command, joins the thread, and removes the worker from tracking.
Returns the worker object.
"""
try:
# Go through all bridge workers to find the worker with the matching thread name.
for bridge_worker_list in list(self._connection_string_workers_map.values()):
for bridge_worker in bridge_worker_list:
if bridge_worker.thread_name == thread_name:
bridge_worker.should_shutdown = True
bridge_worker.action_queue.put(system_messages.SystemStopThreadMessage(), False)
bridge_worker.process.join()
bridge_worker_list.remove(bridge_worker)
return bridge_worker
# If we didn't return from the above loop, we did not find a matching worker to the thread name given.
return None#raise Exception("Bridge worker does not exist: {0}".format(thread_name))
except:
raise ExceptionFormatter.get_full_exception()
示例5: _handle_command_remote_connect_request
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def _handle_command_remote_connect_request(self, message):
"""
Returns True/False depending on if the message was handled or not.
"""
try:
# Notify.
notification_string = "Command received: Remote connect. IP: {0}; Port: {1}; Count: {2}".format(message.remote_ip_address, message.remote_port, message.count)
self.logger.log_info(notification_string)
# Get the connection string and create and register a new bridge worker.
connection_string = ZmqUtilities.get_socket_connection_string(message.remote_ip_address, message.remote_port)
# Create <count> new bridge workers with the connection string.
for _ in range(message.count):
# Create and add a new worker with the connection info.
bridge_worker = self._bridge_worker_manager.create_and_add_worker(connection_string)
bridge_worker.process.start()
# Return success.
return True
except:
raise ExceptionFormatter.get_full_exception()
示例6: send
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def send(self, socket):
"""
Sends the message over the socket.
"""
try:
if self.master_setup_data_message != None:
master_setup_data_message = self.master_setup_data_message.dump()
else:
master_setup_data_message = ""
if self.master_control_data_message != None:
master_control_data_message = self.master_control_data_message.dump()
else:
master_control_data_message = ""
BaseMessage._send_with_destination_and_delimiter(self, socket, self.reply_id_tag,
bson.dumps(self.settings_dict),
self.sender_dealer_id_tag,
str(self.sender_master_flag),
master_setup_data_message, master_control_data_message,
str(self.master_synchronization_failure_flag),
str(self.ping_back_success_flag))
except:
raise ExceptionFormatter.get_full_exception()
示例7: create_and_add_worker
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def create_and_add_worker(self, connection_string):
try:
# Get the next thread index; update the tracker.
thread_index = self._connection_string_last_thread_index_map.get(connection_string, 0) + 1
self._connection_string_last_thread_index_map[connection_string] = thread_index
# Get the thread name.
thread_name = connection_string + "_" + str(thread_index)
# Create the process.
notification_queue = Queue()
data_worker_process = Process(target=bridge_worker_thread,
args=(thread_name,
self._zmq_context,
self._worker_router_socket_port,
connection_string, self.config.bridge_worker_remote_poll_timeout,
notification_queue, self._child_thread_notification_queue,),
name=thread_name)
# Create the bridge worker; update the tracker.
bridge_worker = BridgeWorker(thread_name, connection_string, data_worker_process, notification_queue)
self._connection_string_workers_map.setdefault(connection_string, list()).append(bridge_worker)
# Register in our master thread list.
self._master_thread_name_list.append(thread_name)
# Return the worker.
return bridge_worker
except:
raise ExceptionFormatter.get_full_exception()
示例8: send
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def send(self, socket):
"""
Sends the message over the socket.
"""
try:
BaseMessage._send(self, socket, self.queue_name, self.routing_key, bson.dumps({self.routing_key: self.data}))
except:
raise ExceptionFormatter.get_full_exception()
示例9: create_from_received
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def create_from_received(raw_message, sender_id_string):
"""
Returns a new message of this type from the raw message data.
"""
try:
return PeerRequestMasterDataMessage(None, sender_id_string)
except:
raise ExceptionFormatter.get_full_exception()
示例10: __init__
# 需要导入模块: from afqueue.common.exception_formatter import ExceptionFormatter [as 别名]
# 或者: from afqueue.common.exception_formatter.ExceptionFormatter import get_full_exception [as 别名]
def __init__(self, name, queue_type):
try:
self.name = name
self.type = queue_type
except:
raise ExceptionFormatter.get_full_exception()