Functions imported from my modules executed twice when using Bokeh server

Hi team,

I have a simple bokeh data visualization. The code is organized in the following way:

···

================================================================

  • data.py
  • process_map_data

  • process_ts_data

  • main.py

================================================================

process_map_data & process_ts_data are simply helper functions for querying.

def process_map_data(end_date):

  • …*

  • print "Finished processing [map data] … "*

def process_ts_data(end_date):

  • …*

  • print "Finished processing [ts data] … "*

In the main.py file, I imported the two functions because they are convenient to use, very much in the same style as the Gapminder example on the official website.

from data import process_map_data, process_ts_data

zip_date_ranges, countries_list, source, sources = process_map_data(end_date = ‘2016-10-10’)

markets_list, ts_event, ts_events, ts_source, ts_sources = process_ts_data(end_date = ‘2017-01-01’)

However, when I run the server, I couldn’t quite figure out why these functions get executed twice when I use bokeh server? Here is an example of my log:

2016-10-20 23:01:13,210 Starting Bokeh server version 0.12.3

2016-10-20 23:01:13,215 Starting Bokeh server on port 5006 with applications at paths [’/main’]

2016-10-20 23:01:13,215 Starting Bokeh server with process id: 4867

2016-10-20 23:01:18,788 302 GET / (::1) 0.53ms

Query: WARNING: Loading from cache

Query: INFO: Completed in 0.21 seconds.

Finished processing [map data] …

Query: WARNING: Loading from cache

Query: INFO: Completed in 0.89 seconds.

Finished processing [ts data] …

2016-10-20 23:02:17,145 200 GET /main (::1) 58354.23ms

2016-10-20 23:02:17,146 302 GET / (::1) 0.36ms

Query: WARNING: Loading from cache:

Query: INFO: Completed in 0.22 seconds.

then the sam two functions get executed again !?

Finished processing [map data] …

*Query: WARNING: Loading from cache *

Query: INFO: Completed in 1.03 seconds.

Finished processing [ts data] …

2016-10-20 23:03:17,070 200 GET /demand_index (::1) 59919.84ms

Why do my functions get executed twice? (Happy to provide more code)

Thanks