# Buggy code
async def start_bot(bot, logger, catch=False):
    try:
        loop = asyncio.get_event_loop()
        # try to init
        await bot.create_services()
        await bot.create_exchange_traders()
        bot.create_evaluation_tasks()

        # try to start
        await bot.start_tasks()

        # join threads in a not loop blocking executor
        # TODO remove this when no thread anymore
        await loop.run_in_executor(None, bot.join_threads)

    except Exception as e:
        logger.exception(f"OctoBot Exception : {e}")
        if not catch:
            raise e
        Commands.stop_bot(bot)


# Traceback (concurrent.futures._base.CancelledError)
Traceback (most recent call last):
File "/home/herklos/dev/Drakkars/OctoBot/evaluator/Updaters/global_price_updater.py", line 163, in _refresh_time_frame_data
await self._refresh_data(time_frame, symbol, notify=notify)
File "/home/herklos/dev/Drakkars/OctoBot/evaluator/Updaters/global_price_updater.py", line 177, in _refresh_data
return_list=False))
File "/home/herklos/dev/Drakkars/OctoBot/trading/exchanges/exchange_dispatcher.py", line 89, in get_symbol_prices
await self.exchange.get_symbol_prices(symbol=symbol, time_frame=time_frame, limit=limit)
File "/home/herklos/dev/Drakkars/OctoBot/trading/exchanges/rest_exchanges/rest_exchange.py", line 126, in get_symbol_prices
candles = await self.client.fetch_ohlcv(symbol, time_frame.value)
File "/home/herklos/.local/lib/python3.7/site-packages/ccxt/async_support/binance.py", line 503, in fetch_ohlcv
response = await self.publicGetKlines(self.extend(request, params))
File "/home/herklos/.local/lib/python3.7/site-packages/ccxt/async_support/binance.py", line 1114, in request
response = await self.fetch2(path, api, method, params, headers, body)
File "/home/herklos/.local/lib/python3.7/site-packages/ccxt/async_support/base/exchange.py", line 113, in fetch2
await self.throttle()
concurrent.futures._base.CancelledError
2019-01-19 19:05:51,432 ERROR    GlobalPriceUpdater    when refreshing data for time frame TimeFrames.FOUR_HOURS:
2019-01-19 19:05:51,432 ERROR    GlobalPriceUpdater
Traceback (most recent call last):
File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/herklos/dev/Drakkars/OctoBot/evaluator/Updaters/global_price_updater.py", line 163, in _refresh_time_frame_data
await self._refresh_data(time_frame, symbol, notify=notify)
File "/home/herklos/dev/Drakkars/OctoBot/evaluator/Updaters/global_price_updater.py", line 177, in _refresh_data
return_list=False))
File "/home/herklos/dev/Drakkars/OctoBot/trading/exchanges/exchange_dispatcher.py", line 89, in get_symbol_prices
await self.exchange.get_symbol_prices(symbol=symbol, time_frame=time_frame, limit=limit)
File "/home/herklos/dev/Drakkars/OctoBot/trading/exchanges/rest_exchanges/rest_exchange.py", line 126, in get_symbol_prices
candles = await self.client.fetch_ohlcv(symbol, time_frame.value)
File "/home/herklos/.local/lib/python3.7/site-packages/ccxt/async_support/binance.py", line 503, in fetch_ohlcv
response = await self.publicGetKlines(self.extend(request, params))
File "/home/herklos/.local/lib/python3.7/site-packages/ccxt/async_support/binance.py", line 1114, in request
response = await self.fetch2(path, api, method, params, headers, body)
File "/home/herklos/.local/lib/python3.7/site-packages/ccxt/async_support/base/exchange.py", line 113, in fetch2
await self.throttle()
concurrent.futures._base.CancelledError

# Fixed code
async def start_bot(bot, logger, catch=False):
    try:
        Commands.BOT = bot
        loop = asyncio.get_event_loop()

        # handle CTRL+C signal
        signal.signal(signal.SIGINT, Commands._signal_handler)

        # init
        await bot.create_services()
        await bot.create_exchange_traders()
        bot.create_evaluation_tasks()

        # start
        try:
            await bot.start_tasks()
        except CancelledError:
            logger.info("Core engine tasks cancelled.")

        # join threads in a not loop blocking executor
        # TODO remove this when no thread anymore
        await loop.run_in_executor(None, bot.join_threads)

    except Exception as e:
        logger.exception(f"OctoBot Exception : {e}")
        if not catch:
            raise e
        Commands.stop_bot(bot)