
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
github.com/DACUS1995/async-executor
Small module that allows to easily schedule single asynchronous jobs or create asynchronous tasks that sequentially execute the grouped jobs.
By simply adding a new job to the executor, that job is inserted in a queue that is accessible by every created worker.
Every worker has access to two job queues, one shared and one private. The private queue is used by jobs tasks to ensure the sequential execution of the provided functions.
When waiting for the result there are two options: call Await()
on that job or keep searching for job's id in the executor GlobalResponseQueue.
After making sure that Go is installed on your device. You can use the following command in your terminal:
go get github.com/DACUS1995/async-executor
Add following line in your *.go
file:
import "github.com/DACUS1005/async-executor"
If you are unhappy to use long asyncexecutor
, you can do something like this:
import (
async "github.com/DACUS1005/async-executor"
)
queueSize := 10
numWorkers := 5
executor := NewExecutor(queueSize)
executor.StartExecutor(numWorkers)
job := executor.CreateJob(
func(str string) (string, error) {
return str, nil
},
[]interface{}{"Done"}, // the function parameters
)
returnValue := job.Await()
fmt.Println(returnValue.Responses[0])
executor.Stop()
queueSize := 10
numWorkers := 1
testFunction := func(str string) (string, error) {
return str, nil
}
executor := NewExecutor(queueSize)
executor.StartExecutor(numWorkers)
taskList := []*Job{}
for i := 0; i < queueSize; i++ {
taskList = append(taskList, executor.CreateTaskJob(
testFunction,
[]interface{}{expected},
))
}
lastJob := executor.CreateTask(taskList)
lastJob.Await()
executor.Stop()
type CustomHandler struct{}
func (*CustomHandler) Handle(response *ResponseObject) {
fmt.Printf("Finished job: %v", response.ID)
}
executor.SetResponseHandler(&CustomHandler{})
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.