找到了我的一些问题的答案,html5网络工作者!!!
如何使用此基本示例将参数传递给Web worker?
worker.js的内容:
function doSomething() {
postMessage( ' done');
}
setTimeout ( "doSomething()", 3000 );
js code:
var worker = new Worker('worker.js');
worker.onmessage = function (event) {
alert(event.data);
};
答案 0 :(得分:31)
正如您所看到的,对于worker-to-main和main-to-worker消息,您具有相同的机制。
postMessage
发送消息的方法onmessage
成员在主脚本中:
worker.postMessage(data);
在工作人员脚本中:
self.addEventListener("message", function(e) {
// the passed-in data is available via e.data
}, false);
......或者只是......
onmessage = function(e) {
// the passed-in data is available via e.data
};
可能是数据必须是字符串...(Firefox 3.5+支持传入兼容JSON的对象)
答案 1 :(得分:0)
import os
import sys
import pandas as pd
import odbc as pyodbc
import os
import sys
import re
from pyspark import SparkContext
from pyspark.sql import SQLContext
from pyspark.sql.types import *
from pyspark.sql import Row
from pyspark.sql.functions import *
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import pyspark.sql.functions as func
import matplotlib.patches as mpatches
import time as time
from matplotlib.patches import Rectangle
import datetime
from pyspark import SparkContext, SparkConf
from pyspark.sql import SQLContext
conf = SparkConf()
conf.setMaster("local")
conf.setAppName("AppName")
sqlCtx = SQLContext(sc)
这项工作对我来说