使用积雪暴露来自节点的警告

问题描述

我使用sNow进行了并行处理。除显示的任何警告似乎只是被忽略而不会显示用户之外,此方法工作正常。有没有一种方法可以在各个节点上公开警告,以便它们在主要的R流程中得以通过?

目前,我最好的办法是让所有节点将警告写到文件中,并在最后读取警告,但是必须有更好的方法

这里是一个代表:

library(sNow)

f <- function(x){
  warning("mywarning")
  return(NULL)
}

cl <- makeCluster(2,type="SOCK")

lapply(1:2,f)  # Gives me warnings,as desired
clusterapply(cl,1:2,f)  # Gives me the same output,faster,but with no warnings

解决方法

最后,我最终从snow切换到@bot.command(pass_contex = True) async def Dragning(ctx,num): embed = discord.Embed(title="Dragning") try: arg = random.randint(1,int(num)) except ValueError: return await ctx.channel.send("Endast hela nummer") else: return await ctx.channel.send(str,embed=Embed(arg)) 软件包(与future.apply结合使用)。 parallel现在默认具有此行为。

不幸的是,在大多数情况下,直到整个运行结束,消息/警告才会出现,但这是一个全新的问题。