コード例 #1
0
// NewCoProcessDispatcher wraps all the actions needed for this CP.
func NewCoProcessDispatcher() (dispatcher coprocess.Dispatcher, err error) {

	workDir, _ := os.Getwd()

	dispatcherPath := path.Join(workDir, "coprocess/python")
	middlewarePath := path.Join(workDir, "middleware/python")
	eventHandlerPath := path.Join(workDir, "event_handlers")
	protoPath := path.Join(workDir, "coprocess/python/proto")

	paths := []string{dispatcherPath, middlewarePath, eventHandlerPath, protoPath}

	// Append bundle paths:
	bundlePaths := getBundlePaths()
	for _, v := range bundlePaths {
		paths = append(paths, v)
	}

	PythonSetEnv(paths...)

	PythonInit()
	PythonLoadDispatcher()

	dispatcher, err = PythonNewDispatcher(middlewarePath, eventHandlerPath, bundlePaths)

	C.PyEval_ReleaseLock()

	if err != nil {
		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Error(err)
	}

	return dispatcher, err
}
コード例 #2
0
ファイル: lock.go プロジェクト: ericsnowcurrently/qur-gopy
func ReleaseGil() {
	C.PyEval_ReleaseLock()
}