我需要从下面代码的第二个函数返回一个布尔值。但是,返回class Main_func:
def calculate(self,data):
#do some things with the DF
return df.copy(deep=True) <- one of many attempts to fix the problem, but didnt work
cpus = 24
actors = []
for _ in range(cpus):
actors.append(Main_func.remote())
from ray.util import ActorPool
pool = ActorPool(actors)
import os
arr = os.listdir("/some/files")
def to_ray():
try:
filename = arr.pop(0)
pf = ParquetFile("/some/files/" + filename)
df = pf.to_pandas()
pool.submit(lambda a,v:a.calculate.remote(v),df.copy(deep=True)
except Exception as e:
print(e)
for _ in range(cpus):
to_ray()
while(True):
res = pool.get_next_unordered()
write('./temp/' + random_filename, res,compression='GZIP')
del res
to_ray()
给我isValidOrg
,而console.logging变量给了我所需的答案。在我的情况下,是否有可能返回0或1?
Promise { <pending> }
const GetOrganization = userId => {
return User.aggregate([
{ $match: { _id: mongoose.Types.ObjectId(userId) } },
{
$project: {
_id: 0,
organization: 1
}
}
])
}
答案 0 :(得分:0)
这个用例是完全错误的。
const isValidOrg = await GetOrganization(_id).then(res => {
return xOrg !== res[0].organization ? 0 : 1
})
为什么要链接。然后,只需将其分配给isValidOrg并在下一行对其进行评估。