Skip to content

Commit

Permalink
[ontopy] feederPublisher synchro with spin_once
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Jan 23, 2024
1 parent 6950519 commit f127e85
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ontopy/ontologenius/FeederPublisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def getNumPublishers(self):
def waitConnected(self):
"""Blocks while no subscribers are currently connected to the internal ROS publisher."""
while not Ontoros.isShutdown() and self.getNumSubscribers() == 0 and self.getNumPublishers() == 0:
time.sleep(.01)
Ontoros().spin_once()

def waitUpdate(self, timeout = 100000000):
"""Waits until all changes have been applied.
Expand All @@ -180,8 +180,8 @@ def waitUpdate(self, timeout = 100000000):
start_time = datetime.now()
self._sendNop()

while not Ontoros.isShutdown() and not self._updated and (self.millis_interval(start_time, datetime.now()) < timeout) :
time.sleep(.001)
while not Ontoros().isShutdown() and not self._updated and (self.millis_interval(start_time, datetime.now()) < timeout) :
Ontoros().spin_once()

if self._updated == True:
return True
Expand Down Expand Up @@ -212,10 +212,10 @@ def commit(self, commit_name, timeout = 100000000):
msg = '[commit]' + commit_name + '|'

start_time = datetime.now()
self._publish_stamped(msg, Ontoros.getRosTime())
self._publish_stamped(msg, Ontoros().getRosTime())

while not Ontoros.isShutdown() and not self._updated and (self.millis_interval(start_time, datetime.now()) < timeout) :
time.sleep(.001)
while (not Ontoros().isShutdown()) and (not self._updated) and ((self.millis_interval(start_time, datetime.now()) < timeout)) :
Ontoros().spin_once()

if self._updated == True:
return True
Expand All @@ -231,10 +231,10 @@ def checkout(self, commit_name, timeout = 100000000):
self._updated = False

start_time = datetime.now()
self._publish_stamped('[checkout]' + commit_name + '|', Ontoros.getRosTime())
self._publish_stamped('[checkout]' + commit_name + '|', Ontoros().getRosTime())

while not Ontoros.isShutdown() and not self._updated and (self.millis_interval(start_time, datetime.now()) < timeout) :
time.sleep(.001)
while not Ontoros().isShutdown() and not self._updated and (self.millis_interval(start_time, datetime.now()) < timeout) :
Ontoros().spin_once()

if self._updated == True:
return True
Expand Down

0 comments on commit f127e85

Please sign in to comment.