Skip to content
Snippets Groups Projects
Commit 1e1402d2 authored by rswindell's avatar rswindell
Browse files

Added lines_per_yield (defaults to 10) for importing newsgroup articles, no

longer consume 100% CPU while importing.
parent 10c15891
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,7 @@ var reset_export_ptrs = false; // Reset export pointers, export all messages
var update_export_ptrs = false; // Update export pointers, don't export anything
var email_addresses = true; // Include e-mail addresses in headers
var import_amount = 0; // Import a fixed number of messages per group
var lines_per_yield = 10; // Release time-slices ever x number of lines
// Parse arguments
for(i=0;i<argc;i++) {
......@@ -153,6 +154,9 @@ while(!cfg_file.eof) {
tagline=str.join(' '); // Combine remaining elements (tagline)
tagline+="\r\n";
break;
case "lines_per_yield":
lines_per_yield=Number(str[1]);
break;
default:
printf("!UNRECOGNIZED configuration keyword: %s\r\n",str[0]);
break;
......@@ -427,6 +431,7 @@ for(i in area) {
body="";
header=true;
var hdr={ from: "", to: newsgroup, subject: "", id: "" };
var line_counter=0;
while(socket.is_connected) {
line = socket.recvline(512 /*maxlen*/, 300 /*timeout*/);
......@@ -452,6 +457,9 @@ for(i in area) {
line=line.slice(1); // Skip prepended dots
body += line;
body += "\r\n";
line_counter++;
if(lines_per_yield && (line_counter%lines_per_yield)==0)
sleep(1);
continue;
}
//print(line);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment