Python send heartbeat
19 Python code examples are found related to "
send heartbeat".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: mavlink_control.py From gr-uaslink with GNU General Public License v3.0 | 8 votes |
def send_heartbeat(self): self.mavlink2.wait_heartbeat() while(self.running): if (self.takeoff!=0): currentimem5=dt.datetime.now()-dt.timedelta(seconds=5) print('in send_heartbeat') print(currentimem5) print(self.last_heartbeat_time) if(currentimem5>self.last_heartbeat_time): #if we have missed all messages for more than 5 seconds print('lost link') self.set_land() if (self.takeoff!=0): self.mavlink2.mav.heartbeat_send(mavutil.mavlink.MAV_TYPE_GCS, mavutil.mavlink.MAV_AUTOPILOT_INVALID, 0, 0, 0) self.set_channel_overrides(self.data) time.sleep(1.0)
Example 2
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 7 votes |
def SendHeartbeat(self, hbThreadEvent) : hbSock = socket(AF_INET, SOCK_DGRAM) hbSock.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) while not hbThreadEvent.isSet(): msg = ( "xpl-stat\n{\nhop=1\nsource=" +str(self.hostname) +"\ntarget=*\n}\nhbeat.app\n{\ninterval=5\nport=" ) msg = ( msg +str(self.port) +"\nremote-ip=" +str(self.LocalIP) +"\nversion=1.2\n}\n" ) hbSock.sendto(msg,("255.255.255.255", 3865)) hbThreadEvent.wait(5*60.0) # Sub routine for monitoring heartbeats
Example 3
Source File: webtrader.py From OdooQuant with GNU General Public License v3.0 | 5 votes |
def send_heartbeat(self): """每隔10秒查询指定接口保持 token 的有效性""" while True: if self.heart_active: try: response = self.balance except: pass self.check_account_live(response) time.sleep(10) else: time.sleep(1)
Example 4
Source File: channel0.py From amqpstorm with MIT License | 5 votes |
def send_heartbeat(self): """Send Heartbeat frame. :return: """ if not self._connection.is_open: return self._write_frame(Heartbeat())
Example 5
Source File: webtrader.py From easytrader with MIT License | 5 votes |
def send_heartbeat(self): """每隔10秒查询指定接口保持 token 的有效性""" while True: if self.heart_active: self.check_login() else: time.sleep(1)
Example 6
Source File: client.py From boto3_type_annotations with MIT License | 5 votes |
def send_task_heartbeat(self, taskToken: str) -> Dict: """ Used by workers to report to the service that the task represented by the specified ``taskToken`` is still making progress. This action resets the ``Heartbeat`` clock. The ``Heartbeat`` threshold is specified in the state machine's Amazon States Language definition. This action does not in itself create an event in the execution history. However, if the task times out, the execution history contains an ``ActivityTimedOut`` event. .. note:: The ``Timeout`` of a task, defined in the state machine's Amazon States Language definition, is its maximum allowed duration, regardless of the number of SendTaskHeartbeat requests received. .. note:: This operation is only useful for long-lived tasks to report the liveliness of the task. See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/states-2016-11-23/SendTaskHeartbeat>`_ **Request Syntax** :: response = client.send_task_heartbeat( taskToken='string' ) **Response Syntax** :: {} **Response Structure** - *(dict) --* :type taskToken: string :param taskToken: **[REQUIRED]** The token that represents this task. Task tokens are generated by the service when the tasks are assigned to a worker (see GetActivityTaskOutput$taskToken ). :rtype: dict :returns: """ pass
Example 7
Source File: connection.py From photon-pump with MIT License | 5 votes |
def send_heartbeat(self) -> asyncio.Future: fut = asyncio.Future() self.log.debug("Sending heartbeat %s to server", self.heartbeat_id) hb = convo.Heartbeat(self.heartbeat_id, direction=convo.Heartbeat.OUTBOUND) await hb.start(self._output) self._fut = fut return fut
Example 8
Source File: client.py From nacos-sdk-python with Apache License 2.0 | 5 votes |
def send_heartbeat(self, service_name, ip, port, cluster_name=None, weight=1.0, metadata=None): logger.info("[send-heartbeat] ip:%s, port:%s, service_name:%s, namespace:%s" % (ip, port, service_name, self.namespace)) beat_data = { "serviceName": service_name, "ip": ip, "port": port, "weight": weight } if cluster_name is not None: beat_data["cluster"] = cluster_name if metadata is not None: beat_data["metadata"] = json.loads(metadata) params = { "serviceName": service_name, "beat": json.dumps(beat_data), } if self.namespace: params["namespaceId"] = self.namespace try: resp = self._do_sync_req("/nacos/v1/ns/instance/beat", None, params, None, self.default_timeout, "PUT") c = resp.read() logger.info("[send-heartbeat] ip:%s, port:%s, service_name:%s, namespace:%s, server response:%s" % (ip, port, service_name, self.namespace, c)) return json.loads(c.decode("UTF-8")) except HTTPError as e: if e.code == HTTPStatus.FORBIDDEN: raise NacosException("Insufficient privilege.") else: raise NacosException("Request Error, code is %s" % e.code) except Exception as e: logger.exception("[send-heartbeat] exception %s occur" % str(e)) raise
Example 9
Source File: charge_point.py From ocpp with MIT License | 5 votes |
def send_heartbeat(self, interval): request = call.HeartbeatPayload() while True: await self.call(request) await asyncio.sleep(interval)
Example 10
Source File: stomp_component.py From resilient-python-api with MIT License | 5 votes |
def send_heartbeat(self, event): if self.connected: LOG.debug("Sending heartbeat") try: self._client.beat() except (StompConnectionError, StompError) as err: event.success = False self.fire(OnStompError(None, err))
Example 11
Source File: trader.py From tushare with BSD 3-Clause "New" or "Revised" License | 5 votes |
def send_heartbeat(self): while True: if self.heart_active: try: response = self.heartbeat() self.check_account_live(response) except: self.login() time.sleep(100) else: time.sleep(10)
Example 12
Source File: OTPClientRepository.py From Pirates-Online-Rewritten with BSD 3-Clause "New" or "Revised" License | 5 votes |
def sendHeartbeat(self): datagram = PyDatagram() datagram.addUint16(CLIENT_HEARTBEAT) self.send(datagram) self.lastHeartbeat = globalClock.getRealTime() self.considerFlush()
Example 13
Source File: protocol.py From asynqp with MIT License | 5 votes |
def send_heartbeat(self, interval): # XXX: Add `last_sent` frame monitoring to not send heartbeats # if traffic was going through socket while True: self.protocol.send_frame(frames.HeartbeatFrame()) yield from asyncio.sleep(interval, loop=self.loop)
Example 14
Source File: agent.py From heartbeats with MIT License | 5 votes |
def send_heartbeat(self, error_msg=''): try: r = requests.post(self.report_server + error_msg, auth=self.auth) except Exception as e: self.logger.exception(e)
Example 15
Source File: _group.py From afkak with Apache License 2.0 | 5 votes |
def send_heartbeat_request(self): # Make the heartbeat request payload = _HeartbeatRequest( group=self.group_id, generation_id=self.generation_id, member_id=self.member_id, ) request_d = self.client._send_request_to_coordinator( group=self.group_id, payload=payload, encoder_fn=KafkaCodec.encode_heartbeat_request, decode_fn=KafkaCodec.decode_heartbeat_response, ) return request_d
Example 16
Source File: main.py From backend with GNU General Public License v2.0 | 5 votes |
def send_heartbeat_to_trade(self): try: self.application_trade_client.sendJSON({'MsgType': '1', 'TestReqID': '0', 'NumActiveConnections': len(self.connections)}) except Exception as e: pass
Example 17
Source File: websocket.py From ontology-python-sdk with GNU Lesser General Public License v3.0 | 5 votes |
def send_heartbeat(self, is_full: bool = False): if self.__id == 0: self.__id = self.__generate_ws_id() msg = dict(Action='heartbeat', Version='V1.0.0', Id=self.__id) return await self.__send_recv(msg, is_full)
Example 18
Source File: sfn.py From pyboto3 with MIT License | 4 votes |
def send_task_heartbeat(taskToken=None): """ Used by activity workers and task states using the callback pattern to report to Step Functions that the task represented by the specified taskToken is still making progress. This action resets the Heartbeat clock. The Heartbeat threshold is specified in the state machine\'s Amazon States Language definition (HeartbeatSeconds ). This action does not in itself create an event in the execution history. However, if the task times out, the execution history contains an ActivityTimedOut entry for activities, or a TaskTimedOut entry for for tasks using the job run or callback pattern. See also: AWS API Documentation Exceptions :example: response = client.send_task_heartbeat( taskToken='string' ) :type taskToken: string :param taskToken: [REQUIRED]\nThe token that represents this task. Task tokens are generated by Step Functions when tasks are assigned to a worker, or in the context object when a workflow enters a task state. See GetActivityTaskOutput$taskToken .\n :rtype: dict ReturnsResponse Syntax{} Response Structure (dict) -- Exceptions SFN.Client.exceptions.TaskDoesNotExist SFN.Client.exceptions.InvalidToken SFN.Client.exceptions.TaskTimedOut :return: {} :returns: SFN.Client.exceptions.TaskDoesNotExist SFN.Client.exceptions.InvalidToken SFN.Client.exceptions.TaskTimedOut """ pass