Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
19788 Lượt xem

.py codes:

 @api.multi
 def plotfig(self,cr):
   x=[1,2,3,4]
   y=[4,7,9,8]
   plt.plot(x,y)
   tem='/tmp/%s.png' % cr['uid']
   plt.savefig(tem)
   pic_data=open(tem,'rb').read()
   self.write({'Pic':base64.encodestring(pic_data)})
   os.remove(tem)

Now when user create a record and clicks button "plotfig", a figure will be shown on "Pic"; all seams ok untill now;

but if the user create another record and clicks button "plotfig" again, he/she will get warning: "RuntimeError: main thread is not in main loop"; sometime the warning is "Fatal Python error: GC object already tracked Aborted" / "Segmentation fault" and the Odoo server will shut down automaticly.

if I click "Ctrl+c" to stop Odoo server, I will also get warning: "RuntimeError: main thread is not in main loop";

I don;t know how to resolve these problems.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

it may caused by using matpltlib , so 

just put this 'plt.switch_backend('agg')'  under 'from maipltlib....' 


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 3 24
1656
0
thg 4 23
2335
1
thg 8 22
4864
1
thg 3 21
4319
2
thg 7 18
29310