adamhajari / spyre

a web application framework for python
MIT License
832 stars 157 forks source link

spyre freeze if it is imported after matplotlib #66

Closed anselmwang closed 2 years ago

anselmwang commented 7 years ago

In below code, spyre is imported after matplotlib. Run this program, open "127.0.0.1:9012" and change company to be any other value, the plotted image will never be drawn. In the "console" panel of chrome, the plot call is always pending.

I am using standard WinPython-64bit-2.7.10.3 package, matplotlib version "matplotlib-1.5.0rc3.dist-info", just installed spyre with "pip install datasprye"

` from future import absolute_import from future import division from future import print_function from future import unicode_literals

import matplotlib.pyplot as plt from spyre import server

class StockExample(server.App): title = "Historical Stock Prices"

inputs = [{     "type":'dropdown',
                "label": 'Company', 
                "options" : [{"label": str(wrongIndex), "value": str(wrongIndex)} for wrongIndex in range(30)],
                "key": 'ticker', 
                "action_id": "update_data"}]

controls = [{   "type" : "hidden",
                "id" : "update_data"}]

outputs = [
{"type":"html",
             "id":"html",
             "control_id" : "update_data"
            },
{ "type" : "plot",
                "id" : "plot",
                "control_id" : "update_data",
                },
                 ]

def getHTML(self, params):
    return "Label: 3"

def getPlot(self, params):
    fig = plt.figure()
    splt1 = fig.add_subplot(1,1,1)
    splt1.plot([1,2],[3,4])

    print("here2") 

    return fig

app = StockExample() app.launch(port=9012)

`

adamhajari commented 6 years ago

but it works if you switch the import order?