async def stop_loop( self, # type: HummingbotApplication skip_order_cancellation: bool = False): self._notify("\nWinding down...") # Restore App Nap on macOS. if platform.system() == "Darwin": import appnope appnope.nap() if self._trading_required and not skip_order_cancellation: # Remove the strategy from clock before cancelling orders, to # prevent race condition where the strategy tries to create more # orders during cancellation. if self.clock: self.clock.remove_iterator(self.strategy) success = await self._cancel_outstanding_orders() if success: # Only erase markets when cancellation has been successful self.markets = {} if self.reporting_module: self.reporting_module.stop() if self.strategy_task is not None and not self.strategy_task.cancelled( ): self.strategy_task.cancel() ExchangeRateConversion.get_instance().stop() self.markets_recorder.stop() if self.kill_switch is not None: self.kill_switch.stop() self.wallet = None self.strategy_task = None self.strategy = None self.market_pair = None self.clock = None self.markets_recorder = None
def disable_qt4(self): """Disable event loop integration with PyQt4. This restores appnapp on OS X """ if _use_appnope(): from appnope import nap nap()
def disable(self): """Disable event loop integration with wxPython. This restores appnapp on OS X """ if _use_appnope(): from appnope import nap nap()
def disable_qt4(self): """DEPRECATED since IPython 5.0 Disable event loop integration with PyQt4. This restores appnapp on OS X """ warn("This function is deprecated since IPython 5.0 and will be removed in future versions.", DeprecationWarning, stacklevel=2) if _use_appnope(): from appnope import nap nap()
async def stop_loop( self, # type: HummingbotApplication skip_order_cancellation: bool = False): self.logger().info("stop command initiated.") self._notify("\nWinding down...") # Restore App Nap on macOS. if platform.system() == "Darwin": import appnope appnope.nap() if self._script_iterator is not None: self._script_iterator.stop(self.clock) if self._trading_required and not skip_order_cancellation: # Remove the strategy from clock before cancelling orders, to # prevent race condition where the strategy tries to create more # orders during cancellation. if self.clock: self.clock.remove_iterator(self.strategy) success = await self._cancel_outstanding_orders() # Give some time for cancellation events to trigger await asyncio.sleep(0.5) if success: # Only erase markets when cancellation has been successful self.markets = {} if self.strategy_task is not None and not self.strategy_task.cancelled( ): self.strategy_task.cancel() if EthGasStationLookup.get_instance().started: EthGasStationLookup.get_instance().stop() if self.markets_recorder is not None: self.markets_recorder.stop() if self.kill_switch is not None: self.kill_switch.stop() self.wallet = None self.strategy_task = None self.strategy = None self.market_pair = None self.clock = None self.markets_recorder = None self.market_trading_pairs_map.clear()
def test_nope(): assert appnope.napping_allowed() appnope.nope() assert not appnope.napping_allowed() or sys.platform != "Darwin" appnope.nap() assert appnope.napping_allowed()
from config.config import create_logger from data_collection.extract_text import scrape_urls from yahoo_fin import stock_info as si from multiprocessing import Pool import appnope if __name__ == '__main__': logger = create_logger('stockai.log') logger.info('::::::::Starting text extraction::::::::') tickers = si.tickers_sp500() # tickers = ['MSFT'] #for testing appnope.nope() p = Pool() result = p.map_async(scrape_urls, tickers) p.close() p.join() appnope.nap() logger.info(f'Finished text extraction')