Mar 11 13:08:08 emApp1 sh: fatal error: concurrent map writes
Mar 11 13:08:08 emApp1 sh: fatal error: concurrent map writes
Mar 11 13:08:08 emApp1 sh: goroutine 263309 [running]:
Mar 11 13:08:08 emApp1 sh: runtime.throw(0x7f442b48ffdd, 0x15)
Mar 11 13:08:08 emApp1 sh: /usr/local/go/src/runtime/panic.go:617 +0x74 fp=0xc0000b52a8 sp=0xc0000b5278 pc=0x7f442adcbd24
Mar 11 13:08:08 emApp1 sh: runtime.mapassign_faststr(0xeffc40, 0xc00046f980, 0x7f442b488746, 0x8, 0x0)
Mar 11 13:08:08 emApp1 sh: /usr/local/go/src/runtime/map_faststr.go:291 +0x41d fp=0xc0000b5310 sp=0xc0000b52a8 pc=0x7f442adb2f7d
Mar 11 13:08:08 emApp1 sh: plugin/unnamed-749522c622ea16a892fb5c1bc7d3cec23518df8f.SiteController(0x7f4444c99cd0, 0xc0001100c0, 0xc0000f0c00)
Mar 11 13:08:08 emApp1 sh: /home/gitlab-runner/builds/BMuFqxHZ/0/auth/rt/frontend/vm/controllers/SiteController.go:76 +0x1490 fp=0xc0000b5500 sp=0xc0000b5310 pc=0x7f442b483280
Mar 11 13:08:08 emApp1 sh: github.com/urfave/negroni.WrapFunc.func1(0x7f4444c99cd0, 0xc0001100c0, 0xc0000f0c00, 0xc000149120)
Mar 11 13:08:08 emApp1 sh: /go/pkg/mod/github.com/urfave/negroni@v1.0.0/negroni.go:56 +0x43 fp=0xc0000b5528 sp=0xc0000b5500 pc=0xa6fd03
if node.Params.GetBy == "publicId" {
....
}
concurrent map writes
func SiteController(w http.ResponseWriter, r *http.Request) {
bsonQuery := bson.M{}
if node.Params.ExtendFilter != nil {
bsonQuery = node.Params.ExtendFilter
}
....
doc, err := documents.GetDocumentFrontend(bsonQuery, true)
}
import concurrent.futures
import tornado.ioloop
import tornado.web
import tornado.gen
import time
thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=4)
def demo_future(func):
def wrap(*args, **kwargs):
return thread_pool.submit(func, *args, **kwargs)
return wrap
@demo_future
def fucking_lock(req):
print('lock')
time.sleep(10)
req.write('hello user')
class MainHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
print('hello mf')
yield fucking_lock(self)
def create_app():
return tornado.web.Application([
(r'/', MainHandler)
])
app = create_app()
app.listen(8888)
tornado.ioloop.IOLoop.instance().start()